2012-02-15 06:26:41 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
'use strict';
|
|
|
|
|
2011-10-22 11:24:26 +00:00
|
|
|
Ox.load('UI', {
|
|
|
|
debug: false,
|
|
|
|
hideScreen: false,
|
|
|
|
loadImages: true,
|
|
|
|
showScreen: true,
|
|
|
|
theme: 'modern'
|
|
|
|
}, function() {
|
|
|
|
window.pandora = new Ox.App({url: '/api/'}).bindEvent({
|
|
|
|
load: function(data) {
|
|
|
|
Ox.extend(pandora, {
|
|
|
|
site: data.site,
|
|
|
|
user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user,
|
|
|
|
ui: {},
|
2012-02-15 06:26:41 +00:00
|
|
|
clip: function(options) {
|
2011-10-22 11:24:26 +00:00
|
|
|
var that = Ox.Element();
|
2012-02-15 06:26:41 +00:00
|
|
|
pandora.api.get({id: options.item, keys: []}, function(result) {
|
2011-10-22 11:24:26 +00:00
|
|
|
var video = {};
|
|
|
|
pandora.site.video.resolutions.forEach(function(resolution) {
|
|
|
|
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
2011-11-27 21:49:58 +00:00
|
|
|
var part = (i + 1),
|
|
|
|
prefix = pandora.site.site.videoprefix.replace('PART', part);
|
2012-02-15 06:26:41 +00:00
|
|
|
return prefix + '/' + options.item + '/'
|
2011-11-27 21:49:58 +00:00
|
|
|
+ resolution + 'p' + part + '.' + pandora.user.videoFormat;
|
2011-10-22 11:24:26 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
that.append(pandora.player = Ox.VideoPlayer({
|
2011-12-29 12:41:28 +00:00
|
|
|
controlsBottom: ['play', 'volume', 'scale', 'timeline', 'position', 'settings'],
|
2011-10-22 11:24:26 +00:00
|
|
|
enableFind: false,
|
|
|
|
enableFullscreen: true,
|
2011-12-29 12:41:28 +00:00
|
|
|
enableKeyboard: true,
|
|
|
|
enableMouse: true,
|
|
|
|
enableTimeline: true,
|
2011-10-22 11:24:26 +00:00
|
|
|
enableVolume: true,
|
|
|
|
externalControls: false,
|
|
|
|
height: document.height,
|
2012-02-15 06:26:41 +00:00
|
|
|
'in': options['in'],
|
|
|
|
out: options.out,
|
|
|
|
paused: options.paused,
|
|
|
|
position: options['in'],
|
|
|
|
poster: '/' + options.item + '/' + '128p' + options['in'] +'.jpg',
|
2012-02-15 06:39:55 +00:00
|
|
|
resolution: pandora.user.ui.videoResolution,
|
2011-12-29 12:41:28 +00:00
|
|
|
showMarkers: false,
|
|
|
|
showMilliseconds: 0,
|
2012-02-15 06:26:41 +00:00
|
|
|
timeline: '/' + options.item + '/' + 'timeline16p.png',
|
2011-10-22 11:24:26 +00:00
|
|
|
title: result.data.title,
|
|
|
|
video: video,
|
2012-02-15 06:26:41 +00:00
|
|
|
width: document.width
|
2011-10-22 11:24:26 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
2012-02-15 06:39:55 +00:00
|
|
|
playing: checkRange,
|
|
|
|
position: checkRange,
|
|
|
|
resolution: function(data) {
|
|
|
|
pandora.api.setUI({'videoResolution': data.resolution});
|
|
|
|
},
|
2011-10-22 11:24:26 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
Ox.UI.hideLoadingScreen();
|
2012-02-15 06:39:55 +00:00
|
|
|
|
|
|
|
function checkRange(data) {
|
|
|
|
if(data.position < options['in']
|
|
|
|
|| data.position > options.out) {
|
|
|
|
if(!pandora.player.options('paused')) {
|
|
|
|
pandora.player.togglePaused();
|
|
|
|
}
|
|
|
|
pandora.player.options({
|
|
|
|
position: options['in'],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2011-10-22 11:24:26 +00:00
|
|
|
});
|
|
|
|
return that;
|
2012-02-15 06:26:41 +00:00
|
|
|
}
|
2011-10-22 11:24:26 +00:00
|
|
|
});
|
|
|
|
Ox.extend(pandora.user, {
|
|
|
|
videoFormat: Ox.UI.getVideoFormat(pandora.site.video.formats)
|
|
|
|
});
|
2012-02-15 06:26:41 +00:00
|
|
|
|
|
|
|
function parseQuery() {
|
|
|
|
var vars = window.location.search.length
|
|
|
|
? window.location.search.substring(1).split('&')
|
|
|
|
: [],
|
|
|
|
query = {
|
|
|
|
item: window.location.pathname.substring(1).split('/')[0]
|
|
|
|
},
|
|
|
|
defaults = {
|
|
|
|
view: 'video',
|
|
|
|
'in': 0,
|
|
|
|
out: 10,
|
|
|
|
paused: true,
|
|
|
|
item: ''
|
|
|
|
};
|
|
|
|
vars.forEach(function(v) {
|
|
|
|
v= v.split('=');
|
|
|
|
query[v[0]] = decodeURIComponent(v[1]);
|
|
|
|
});
|
|
|
|
|
|
|
|
return Ox.extend({}, defaults, query);
|
|
|
|
}
|
|
|
|
var options = parseQuery();
|
|
|
|
if (options.view == 'video') {
|
|
|
|
pandora.ui.info = pandora.clip(options)
|
|
|
|
.css({width: '100%', height: '100%'})
|
|
|
|
.appendTo(document.body);
|
|
|
|
}
|
2011-10-22 11:24:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|