2011-10-07 09:59:27 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
2011-10-07 09:59:27 +00:00
|
|
|
pandora.ui.clipPlayer = function() {
|
2011-10-08 09:57:02 +00:00
|
|
|
// FIXME: is clipPlayer the best name for this?
|
2011-10-07 09:59:27 +00:00
|
|
|
var that = Ox.VideoPlayer({
|
|
|
|
controlsBottom: ['play', 'previous', 'next', 'volume'],
|
|
|
|
controlsTop: ['fullscreen', 'scale'],
|
|
|
|
enableMouse: true,
|
|
|
|
height: 384,
|
|
|
|
paused: true,
|
|
|
|
position: 0,
|
|
|
|
video: function(range, callback) {
|
|
|
|
var callback = arguments[arguments.length - 1],
|
|
|
|
range = arguments.length == 2 ? arguments[0] : null,
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery = pandora.user.ui.find,
|
2011-10-07 09:59:27 +00:00
|
|
|
query = {conditions:[]};
|
|
|
|
//fixme: can this be in pandora.Query? dont just check for subtitles
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery.conditions.forEach(function(q) {
|
2011-10-07 09:59:27 +00:00
|
|
|
if (q.key == 'subtitles') {
|
|
|
|
query.conditions.push({key: 'subtitles', value: q.value, operator: q.operator});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
pandora.api.findClips(Ox.extend({
|
|
|
|
query: query,
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery: itemsQuery
|
2011-10-07 09:59:27 +00:00
|
|
|
}, range ? {
|
|
|
|
keys: ['id', 'in', 'out', 'subtitles'],
|
|
|
|
range: range,
|
|
|
|
sort: pandora.user.ui.listSort
|
|
|
|
} : {}), function(result) {
|
2011-11-04 15:54:42 +00:00
|
|
|
//Ox.Log('', 'API findClips range', range, 'result', result.data);
|
2011-10-07 09:59:27 +00:00
|
|
|
if (!range) {
|
|
|
|
callback(result.data.items);
|
|
|
|
} else {
|
|
|
|
var counter = 0,
|
|
|
|
length = range[1] - range[0],
|
|
|
|
data = [];
|
|
|
|
result.data.items.forEach(function(item, i) {
|
2011-10-29 15:24:54 +00:00
|
|
|
var id = item.id.split('/')[0];
|
2011-10-07 09:59:27 +00:00
|
|
|
pandora.api.get({id: id, keys: ['durations']}, function(result) {
|
2011-11-04 15:54:42 +00:00
|
|
|
//Ox.Log('', 'API get item', id, 'result', result.data);
|
2011-10-07 09:59:27 +00:00
|
|
|
var points = [item['in'], item.out],
|
2011-10-29 17:46:46 +00:00
|
|
|
partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points);
|
2011-10-07 09:59:27 +00:00
|
|
|
data[i] = {
|
|
|
|
parts: partsAndPoints.parts.map(function(i) {
|
2013-03-01 11:23:35 +00:00
|
|
|
return pandora.getVideoURL(item, Ox.min(pandora.site.video.resolutions), i + 1);
|
2011-10-07 09:59:27 +00:00
|
|
|
}),
|
|
|
|
points: partsAndPoints.points
|
2011-10-29 15:24:54 +00:00
|
|
|
};
|
2011-10-07 09:59:27 +00:00
|
|
|
if (++counter == length) {
|
|
|
|
callback(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
width: 512
|
|
|
|
});
|
|
|
|
return that;
|
|
|
|
};
|