move clip player to file and fix video results view

This commit is contained in:
j 2011-10-07 11:59:27 +02:00
parent d117dfe351
commit d60a3d74e1
3 changed files with 63 additions and 57 deletions

View file

@ -0,0 +1,59 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.clipPlayer = function() {
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,
itemQuery = pandora.user.ui.find,
query = {conditions:[]};
//fixme: can this be in pandora.Query? dont just check for subtitles
itemQuery.conditions.forEach(function(q) {
if (q.key == 'subtitles') {
query.conditions.push({key: 'subtitles', value: q.value, operator: q.operator});
}
});
pandora.api.findClips(Ox.extend({
query: query,
itemQuery: itemQuery
}, range ? {
keys: ['id', 'in', 'out', 'subtitles'],
range: range,
sort: pandora.user.ui.listSort
} : {}), function(result) {
//Ox.print('API findClips range', range, 'result', result.data);
if (!range) {
callback(result.data.items);
} else {
var counter = 0,
length = range[1] - range[0],
data = [];
result.data.items.forEach(function(item, i) {
var id = item.id.split('/')[0]
pandora.api.get({id: id, keys: ['durations']}, function(result) {
//Ox.print('API get item', id, 'result', result.data);
var points = [item['in'], item.out],
partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points);
data[i] = {
parts: partsAndPoints.parts.map(function(i) {
return '/' + id + '/96p' + (i + 1) + '.' + pandora.user.videoFormat;
}),
points: partsAndPoints.points
}
if (++counter == length) {
callback(data);
}
});
});
}
});
},
width: 512
});
return that;
};

View file

@ -226,62 +226,8 @@ pandora.ui.list = function() {
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.'); that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
} else if (view == 'clip') { } else if (view == 'clip') {
that = pandora.ui.clipList(); that = pandora.ui.clipList();
} else if (view == 'player') { } else if (view == 'video') {
that = Ox.VideoPlayer({ that = pandora.ui.clipPlayer();
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,
itemQuery = pandora.user.ui.find,
query = {conditions:[]};
//fixme: can this be in pandora.Query? dont just check for subtitles
itemQuery.conditions.forEach(function(q) {
if (q.key == 'subtitles') {
query.conditions.push({key: 'value', value: q.value, operator: q.operator});
}
});
pandora.api.findClips(Ox.extend({
query: query,
itemQuery: itemQuery
}, range ? {
keys: ['id', 'in', 'out', 'subtitles'],
range: range,
sort: pandora.user.ui.listSort
} : {}), function(result) {
//Ox.print('API findAnnotations range', range, 'result', result.data);
if (!range) {
callback(result.data.items);
} else {
var counter = 0,
length = range[1] - range[0],
data = [];
result.data.items.forEach(function(item, i) {
var id = item.id.split('/')[0]
pandora.api.get({id: id, keys: ['durations']}, function(result) {
//Ox.print('API get item', id, 'result', result.data);
var points = [item['in'], item.out],
partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points);
data[i] = {
parts: partsAndPoints.parts.map(function(i) {
return '/' + id + '/96p' + (i + 1) + '.' + pandora.user.videoFormat;
}),
points: partsAndPoints.points
}
if (++counter == length) {
callback(data);
}
});
});
}
});
},
width: 512
});
} else if (['map', 'calendar'].indexOf(view) > -1) { } else if (['map', 'calendar'].indexOf(view) > -1) {
that = pandora.ui.navigationView(view); that = pandora.ui.navigationView(view);
} else { } else {

View file

@ -52,5 +52,6 @@
"js/pandora/ui/usersDialog.js", "js/pandora/ui/usersDialog.js",
"js/pandora/ui/videoPreview.js", "js/pandora/ui/videoPreview.js",
"js/pandora/ui/viewSelect.js", "js/pandora/ui/viewSelect.js",
"js/pandora/ui/helpDialog.js" "js/pandora/ui/helpDialog.js",
"js/pandora/ui/clipPlayer.js"
] ]