From d60a3d74e1f1d5f164427918da3dbf5e36b2ba20 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 7 Oct 2011 11:59:27 +0200 Subject: [PATCH] move clip player to file and fix video results view --- static/js/pandora/ui/clipPlayer.js | 59 ++++++++++++++++++++++++++++++ static/js/pandora/ui/list.js | 58 +---------------------------- static/json/pandora.json | 3 +- 3 files changed, 63 insertions(+), 57 deletions(-) create mode 100644 static/js/pandora/ui/clipPlayer.js diff --git a/static/js/pandora/ui/clipPlayer.js b/static/js/pandora/ui/clipPlayer.js new file mode 100644 index 00000000..eff1a33f --- /dev/null +++ b/static/js/pandora/ui/clipPlayer.js @@ -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; +}; diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 212694ef..699c81cc 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -226,62 +226,8 @@ pandora.ui.list = function() { that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.'); } else if (view == 'clip') { that = pandora.ui.clipList(); - } else if (view == 'player') { - 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: '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 (view == 'video') { + that = pandora.ui.clipPlayer(); } else if (['map', 'calendar'].indexOf(view) > -1) { that = pandora.ui.navigationView(view); } else { diff --git a/static/json/pandora.json b/static/json/pandora.json index 77dfb1aa..8fa207bb 100644 --- a/static/json/pandora.json +++ b/static/json/pandora.json @@ -52,5 +52,6 @@ "js/pandora/ui/usersDialog.js", "js/pandora/ui/videoPreview.js", "js/pandora/ui/viewSelect.js", - "js/pandora/ui/helpDialog.js" + "js/pandora/ui/helpDialog.js", + "js/pandora/ui/clipPlayer.js" ]