oxjs/demos/video/js/video.js

272 lines
9.5 KiB
JavaScript
Raw Normal View History

Ox.load('UI', {
debug: true,
theme: 'modern'
}, function() {
2011-05-15 16:18:58 +00:00
var $foo, $bar;
2011-05-14 19:32:49 +00:00
var id = '0393109',
2011-05-15 08:35:00 +00:00
poster = 'png/poster.png',
2011-05-15 16:18:58 +00:00
results = [
{'in': 190.335, out: 192.353},
{'in': 1185.215, out: 1188.115},
{'in': 1784.525, out: 1785.915},
{'in': 1786.015, out: 1787.835},
{'in': 3087.365, out: 3090.275},
{'in': 3704.915, out: 3706.795},
{'in': 3706.895, out: 3709.615},
{'in': 4061.655, out: 4063.95},
{'in': 4531.775, out: 4533.415},
{'in': 4946.095, out: 4948.875},
{'in': 5292.885, out: 5294.665},
{'in': 5381.965, out: 5383.338},
{'in': 5385.415, out: 5389.58},
{'in': 5434.93, out: 5436.93},
{'in': 5437.405, out: 5439.405},
{'in': 5749.535, out: 5751.915},
{'in': 5780.235, out: 5782.435},
{'in': 5881.365, out: 5886.635}
],
timeline = 'png/timeline.16.png',
2011-05-14 19:32:49 +00:00
url = 'http://next.0xdb.org/' + id + '/96p.webm',
videoSize = getVideoSize(),
$videos = [
Ox.VideoPlayer({
2011-05-16 18:05:29 +00:00
controlsBottom: ['play', 'volume', 'scale', 'timeline', 'position'],
controlsTop: ['fullscreen', 'title', 'find'],
enableFind: true,
enableFullscreen: true,
2011-05-14 19:32:49 +00:00
enableKeyboard: true,
2011-05-16 18:05:29 +00:00
enableVolume: true,
2011-05-14 19:32:49 +00:00
focus: 'mouseenter',
height: 192,
logoLink: 'http://next.0xdb.org/' + id,
logoTitle: 'Watch on 0xdb',
logo: 'png/logo.png',
paused: true,
poster: poster,
showIconOnLoad: true,
showProgress: false,
subtitles: 'srt/' + id + '.srt',
timeline: function(i) {
return 'png/timeline.16.' + i + '.png';
},
2011-05-16 18:05:29 +00:00
title: 'Brick - Rian Johnson - 2005',
2011-05-14 19:32:49 +00:00
video: url + '?' + + Ox.random(1000000),
width: 360
})
.css({
2011-05-15 07:26:00 +00:00
left: '16px',
top: '16px'
}),
2011-05-14 19:32:49 +00:00
Ox.VideoPlayer({
2011-05-15 07:26:00 +00:00
enableKeyboard: true,
2011-05-15 08:35:00 +00:00
height: videoSize.height,
2011-05-14 19:32:49 +00:00
'in': 3128.725,
//keepIconVisible: true,
out: 3130.725,
paused: true,
playInToOut: true,
//preload: 'none',
showIcon: true,
timeline: timeline,
video: url + '?' + + Ox.random(1000000),
2011-05-15 08:35:00 +00:00
width: videoSize.width
2011-05-14 19:32:49 +00:00
})
.css({
2011-05-15 07:26:00 +00:00
left: '16px',
top: '16px'
2011-05-14 19:32:49 +00:00
}),
Ox.VideoPlayer({
controlsTop: ['fullscreen', 'title', 'find'],
controlsBottom: ['play', 'playInToOut', 'volume', 'size', 'space', 'position'],
enableFind: true,
enableFullscreen: true,
enableVolume: true,
2011-05-14 19:32:49 +00:00
externalControls: true,
2011-05-15 08:35:00 +00:00
height: 192,
2011-05-17 08:58:03 +00:00
'in': 3128.725,
largeTimeline: function(i) {
return 'http://next.0xdb.org/' + id + '/timelines/timeline.64.' + i + '.png';
},
2011-05-14 19:32:49 +00:00
out: 3130.725,
paused: true,
showMilliseconds: 2,
subtitles: 'srt/' + id + '.srt',
timeline: timeline,
title: 'Brick - Rian Johnson - 2005',
2011-05-14 19:32:49 +00:00
video: url + '?' + + Ox.random(1000000),
2011-05-15 08:35:00 +00:00
width: 360
2011-05-14 19:32:49 +00:00
})
.css({
2011-05-15 07:26:00 +00:00
left: '16px',
top: '16px'
})
.bindEvent({
2011-05-15 16:18:58 +00:00
position: function(data) {
$blockTimeline.options({
position: data.position
});
2011-05-15 07:26:00 +00:00
}
2011-05-14 19:32:49 +00:00
})
];
window.$videos = $videos
Ox.SplitPanel({
elements: [
{
element: Ox.SplitPanel({
elements: [
{
element: Ox.Element()
.append($videos[0])
.bindEvent({
resize: function(foo, size) {
$videos[0].options({height: size - 32});
}
}),
size: 224,
resizable: true,
resize: [100, 400]
},
{
2011-05-15 16:18:58 +00:00
element: $foo = Ox.Element()
2011-05-14 19:32:49 +00:00
}
],
orientation: 'vertical'
})
.bindEvent({
resize: function(foo, size) {
$videos[0].options({width: size - 32});
2011-05-15 18:50:05 +00:00
$smallTimeline.options({width: size - 16});
$playerTimeline.options({width: size - 16});
2011-05-14 19:32:49 +00:00
}
}),
size: 392,
resizable: true,
resize: [200, 600]
},
{
element: Ox.Element()
.append($videos[1])
.bindEvent({
resize: resizeVideo
})
},
{
element: Ox.SplitPanel({
elements: [
{
element: Ox.Element()
.append($videos[2])
.bindEvent({
resize: function(foo, size) {
$videos[2].options({height: size - 48});
}
}),
2011-05-17 07:43:20 +00:00
size: 320,
2011-05-14 19:32:49 +00:00
resizable: true,
resize: [100, 400]
},
{
2011-05-15 16:18:58 +00:00
element: $bar = Ox.Element()
2011-05-14 19:32:49 +00:00
}
],
orientation: 'vertical'
})
.bindEvent({
resize: function(foo, size) {
$videos[2].options({width: size - 32});
2011-05-15 18:50:05 +00:00
$blockTimeline.options({width: size - 16});
2011-05-14 19:32:49 +00:00
}
}),
size: 392,
resizable: true,
resize: [200, 600]
}
],
orientation: 'horizontal'
}).appendTo(Ox.UI.$body);
2011-05-14 19:32:49 +00:00
function getVideoSize() {
var size = {},
widths = $videos ? $videos[0].options('width') + $videos[2].options('width') : 720
size.width = window.innerWidth - widths - 98;
size.height = Math.round(size.width / 180 * 96);
return size;
}
function resizeVideo() {
var size = getVideoSize();
$videos[1].options({
width: size.width,
height: size.height
});
}
2011-05-15 16:18:58 +00:00
Ox.get('srt/0393109.srt', function(srt) {
var subtitles = Ox.parseSRT(srt);
$foo.append(
2011-05-15 18:50:05 +00:00
$smallTimeline = Ox.SmallVideoTimeline({
2011-05-15 16:18:58 +00:00
duration: 6336.08,
2011-05-15 18:50:05 +00:00
find: 'brick',
'in': 3128.725,
out: 3130.725,
results: results,
2011-05-15 16:18:58 +00:00
subtitles: subtitles,
2011-05-17 09:43:54 +00:00
timeline: 'png/timeline.16.png',
2011-05-15 16:18:58 +00:00
type: 'editor',
2011-05-15 18:50:05 +00:00
width: 376
})
.css({
position: 'absolute',
left: '4px',
top: '4px'
})
);
$foo.append(
$playerTimeline = Ox.SmallVideoTimeline({
duration: 6336.08,
find: 'brick',
'in': 3128.725,
out: 3130.725,
results: results,
subtitles: subtitles,
2011-05-17 09:43:54 +00:00
timeline: 'png/timeline.16.png',
2011-05-15 18:50:05 +00:00
type: 'player',
width: 376
})
.css({
position: 'absolute',
left: '4px',
top: '32px'
2011-05-15 16:18:58 +00:00
})
);
$bar.append(
$blockTimeline = Ox.BlockVideoTimeline({
duration: 6336.08,
find: 'brick',
'in': 3128.725,
out: 3130.725,
results: results,
2011-05-15 18:50:05 +00:00
showMilliseconds: 2,
2011-05-15 16:18:58 +00:00
subtitles: subtitles,
2011-05-17 09:43:54 +00:00
timeline: function(i) {
return 'png/timeline.16.' + i + '.png';
},
2011-05-15 18:50:05 +00:00
width: 376
2011-05-15 16:18:58 +00:00
})
.css({
position: 'absolute',
2011-05-15 18:50:05 +00:00
left: '4px',
top: '4px'
2011-05-15 16:18:58 +00:00
})
.bindEvent('position', function(data) {
$videos[2].options({
position: data.position
});
})
);
})
});