From 32719a212cb214baa2b3a5a4e9b512244076cf4d Mon Sep 17 00:00:00 2001
From: j <0x006A@0x2620.org>
Date: Wed, 23 Jul 2014 17:45:39 +0200
Subject: [PATCH] pass languages and audio track to player
---
static/js/item.js | 1 +
static/js/player.js | 1 +
static/js/utils.js | 43 ++++++++++++++++++++++++++++++++-----------
3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/static/js/item.js b/static/js/item.js
index baee87219..a8102c324 100644
--- a/static/js/item.js
+++ b/static/js/item.js
@@ -13,6 +13,7 @@ pandora.ui.item = function() {
pandora.api.get({
id: pandora.user.ui.item,
keys: isVideoView ? [
+ 'audioTracks',
'cuts', 'director', 'duration', 'durations', 'editable', 'layers',
'modified', 'parts', 'posterFrame', 'rendered', 'rightslevel',
'size', 'title', 'videoRatio', 'year'
diff --git a/static/js/player.js b/static/js/player.js
index 5028b76de..3e71f9055 100644
--- a/static/js/player.js
+++ b/static/js/player.js
@@ -14,6 +14,7 @@ pandora.ui.player = function(data) {
annotationsSort: ui.annotationsSort,
annotationsTooltip: Ox._('annotations')
+ ' ' + Ox.SYMBOLS.SHIFT + 'A',
+ audioTrack: data.audioTracks ? data.audioTracks[0] : void 0,
censored: data.censored,
censoredIcon: pandora.site.cantPlay.icon,
censoredTooltip: Ox._(pandora.site.cantPlay.text),
diff --git a/static/js/utils.js b/static/js/utils.js
index 40f83c90a..45b18632c 100644
--- a/static/js/utils.js
+++ b/static/js/utils.js
@@ -1738,13 +1738,15 @@ pandora.getMediaURL = function(url) {
return pandora.site.site.mediaprefix + url;
};
-pandora.getVideoURL = function(id, resolution, part) {
+pandora.getVideoURL = function(id, resolution, part, track) {
var prefix = pandora.site.site.videoprefix
.replace('{id}', id)
.replace('{part}', part)
.replace('{resolution}', resolution)
.replace('{uid}', Ox.uid());
- return prefix + '/' + id + '/' + resolution + 'p' + part + '.' + pandora.user.videoFormat;
+ return prefix + '/' + id + '/' + resolution + 'p' + part
+ + (track ? '.' + track : '')
+ + '.' + pandora.user.videoFormat;
};
pandora.getVideoOptions = function(data) {
@@ -1758,12 +1760,14 @@ pandora.getVideoOptions = function(data) {
})[0];
options.subtitles = options.subtitlesLayer
? data.layers[options.subtitlesLayer].map(function(subtitle) {
- return {
+ return Ox.extend({
id: subtitle.id,
'in': subtitle['in'],
out: subtitle.out,
text: subtitle.value.replace(/\n/g, ' ').replace(/
/g, '\n')
- };
+ }, subtitle.languages ? {
+ tracks: subtitle.languages
+ } : {});
})
: [];
options.censored = canPlayVideo ? []
@@ -1788,14 +1792,30 @@ pandora.getVideoOptions = function(data) {
})
)
: [{'in': 0, out: data.duration}];
- options.video = {};
+ options.video = [];
pandora.site.video.resolutions.forEach(function(resolution) {
- options.video[resolution] = Ox.range(data.parts).map(function(i) {
- return {
- duration: data.durations[i],
- src: pandora.getVideoURL(data.item || pandora.user.ui.item, resolution, i + 1)
- };
- });
+ if (data.audioTracks) {
+ data.audioTracks.forEach(function(track) {
+ Ox.range(data.parts).forEach(function(i) {
+ options.video.push({
+ duration: data.durations[i],
+ index: i,
+ track: track,
+ resolution: resolution,
+ src: pandora.getVideoURL(data.item || pandora.user.ui.item, resolution, i + 1, track)
+ });
+ });
+ });
+ } else {
+ Ox.range(data.parts).forEach(function(i) {
+ options.video.push({
+ duration: data.durations[i],
+ index: i,
+ resolution: resolution,
+ src: pandora.getVideoURL(data.item || pandora.user.ui.item, resolution, i + 1)
+ });
+ });
+ }
});
options.annotations = [];
pandora.site.layers.forEach(function(layer, i) {
@@ -1811,6 +1831,7 @@ pandora.getVideoOptions = function(data) {
})
});
});
+ Ox.Log('Video', 'VideoOptions', options);
return options;
};