forked from 0x2620/pandora
add embedded timeline view
This commit is contained in:
parent
8b082023e9
commit
49e20c193a
1 changed files with 116 additions and 59 deletions
|
@ -8,22 +8,25 @@ Ox.load('UI', {
|
|||
showScreen: true,
|
||||
theme: 'modern'
|
||||
}, function() {
|
||||
var videoKeys = [ 'duration', 'layers', 'parts', 'posterFrame', 'rightslevel', 'size', 'title', 'videoRatio' ];
|
||||
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: {},
|
||||
clip: function(options) {
|
||||
var that = Ox.Element(),
|
||||
keys = [ 'duration', 'layers', 'parts', 'posterFrame', 'rightslevel', 'size', 'title', 'videoRatio' ];
|
||||
$ui: {},
|
||||
ui: {
|
||||
player: function(options) {
|
||||
var that = Ox.Element();
|
||||
pandora.user.ui.item = options.item;
|
||||
pandora.api.get({id: options.item, keys: keys}, function(result) {
|
||||
var videoOptions = getVideoOptions(result.data);
|
||||
pandora.api.get({id: options.item, keys: videoKeys}, function(result) {
|
||||
var data = getVideoOptions(result.data);
|
||||
that.append(pandora.player = Ox.VideoPlayer({
|
||||
censored: videoOptions.censored,
|
||||
censored: data.censored,
|
||||
censoredIcon: pandora.site.cantPlay.icon,
|
||||
censoredTooltip: pandora.site.cantPlay.text,
|
||||
controlsBottom: ['play', 'volume', 'scale', 'timeline', 'settings'],
|
||||
duration: result.data.duration,
|
||||
duration: data.duration,
|
||||
enableFind: false,
|
||||
enableFullscreen: true,
|
||||
enableKeyboard: true,
|
||||
|
@ -40,10 +43,10 @@ Ox.load('UI', {
|
|||
resolution: pandora.user.ui.videoResolution,
|
||||
showMarkers: false,
|
||||
showMilliseconds: 0,
|
||||
subtitles: videoOptions.subtitles,
|
||||
subtitles: data.subtitles,
|
||||
timeline: '/' + options.item + '/' + 'timeline16p.png',
|
||||
title: result.data.title,
|
||||
video: videoOptions.video,
|
||||
video: data.video,
|
||||
width: window.innerWidth
|
||||
})
|
||||
.bindEvent({
|
||||
|
@ -56,6 +59,58 @@ Ox.load('UI', {
|
|||
);
|
||||
Ox.UI.hideLoadingScreen();
|
||||
|
||||
});
|
||||
return that;
|
||||
},
|
||||
timeline: function(options) {
|
||||
var that = Ox.Element();
|
||||
pandora.user.ui.item = options.item;
|
||||
pandora.api.get({id: options.item, keys: videoKeys}, function(result) {
|
||||
Ox.UI.hideLoadingScreen();
|
||||
var data = getVideoOptions(result.data),
|
||||
ui = pandora.user.ui;
|
||||
that.append(pandora.player = Ox.VideoTimelinePlayer({
|
||||
censored: data.censored,
|
||||
censoredIcon: pandora.site.cantPlay.icon,
|
||||
censoredTooltip: pandora.site.cantPlay.text,
|
||||
cuts: data.cuts || [],
|
||||
duration: data.duration,
|
||||
followPlayer: ui.followPlayer,
|
||||
getFrameURL: function(position) {
|
||||
return '/' + ui.item + '/' + ui.videoResolution + 'p' + position + '.jpg';
|
||||
},
|
||||
getLargeTimelineURL: function(type, i) {
|
||||
return '/' + ui.item + '/timeline' + type + '64p' + i + '.jpg';
|
||||
},
|
||||
height: that.height(),
|
||||
muted: ui.videoMuted,
|
||||
'in': options['in'],
|
||||
out: options.out,
|
||||
paused: options.paused,
|
||||
position: options['in'],
|
||||
resolution: pandora.site.video.resolutions[0],
|
||||
smallTimelineURL: '/' + ui.item + '/timeline16p.jpg',
|
||||
subtitles: data.subtitles,
|
||||
timeline: ui.videoTimeline,
|
||||
timelines: pandora.site.timelines,
|
||||
video: data.video,
|
||||
videoRatio: data.videoRatio,
|
||||
volume: ui.videoVolume,
|
||||
width: that.width()
|
||||
})
|
||||
.bindEvent({
|
||||
playing: checkRange,
|
||||
position: checkRange,
|
||||
resolution: function(data) {
|
||||
pandora.api.setUI({'videoResolution': data.resolution});
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
return that;
|
||||
}
|
||||
}
|
||||
});
|
||||
function checkRange(data) {
|
||||
if (
|
||||
data.position < options['in'] - 0.04
|
||||
|
@ -69,17 +124,17 @@ Ox.load('UI', {
|
|||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return that;
|
||||
}
|
||||
});
|
||||
Ox.extend(pandora.user, {
|
||||
videoFormat: Ox.UI.getVideoFormat(pandora.site.video.formats)
|
||||
});
|
||||
var options = parseQuery();
|
||||
if (['video', 'player'].indexOf(options.view) > -1) {
|
||||
pandora.ui.info = pandora.clip(options)
|
||||
.css({width: '100%', height: '100%'})
|
||||
pandora.$ui.player = pandora.ui.player(options)
|
||||
.css({top: 0, bottom: 0, left: 0, right: 0, position: 'absolute'})
|
||||
.appendTo(document.body);
|
||||
} else if (options.view == 'timeline') {
|
||||
pandora.$ui.timeline = pandora.ui.timeline(options)
|
||||
.css({top: 0, bottom: 0, left: 0, right: 0, position: 'absolute'})
|
||||
.appendTo(document.body);
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +197,8 @@ Ox.load('UI', {
|
|||
})
|
||||
});
|
||||
});
|
||||
options.duration = data.duration;
|
||||
options.videoRatio = data.videoRatio;
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue