load less videos per clip

This commit is contained in:
rolux 2011-08-19 18:08:51 +00:00
parent a815b3119e
commit 5b49168890
2 changed files with 26 additions and 17 deletions

View file

@ -144,17 +144,26 @@ pandora.getListData = function() {
return data; return data;
}; };
pandora.getVideoPartAndPosition = function(durations, position) { pandora.getVideoPartsAndPoints = function(durations, points) {
var duration = 0, ret; var parts = durations.length,
Ox.forEach(durations, function(d, i) { offsets = Ox.range(parts).map(function(i) {
if (duration + d > position) { return Ox.sum(Ox.sub(durations, 0, i));
}),
ret = { ret = {
part: i, parts: [],
position: position - duration points: []
} };
points.forEach(function(point, i) {
Ox.loop(parts - 1, -1, -1, function(i) {
if (offsets[i] <= point) {
ret.parts[i] = i;
return false; return false;
} }
duration += d; });
});
ret.parts = Ox.unique(ret.parts);
ret.points = points.map(function(point) {
return point - offsets[ret.parts[0]];
}); });
return ret; return ret;
}; };

View file

@ -233,18 +233,18 @@ pandora.ui.list = function() { // fixme: remove view argument
if ($img.length) { if ($img.length) {
var width = parseInt($img.css('width')), var width = parseInt($img.css('width')),
height = parseInt($img.css('height')); height = parseInt($img.css('height'));
pandora.api.get({id: item, keys: ['parts']}, function(result) { pandora.api.get({id: item, keys: ['durations']}, function(result) {
var inPoint = that.value(id, 'in'), var points = [that.value(id, 'in'), that.value(id, 'out')],
outPoint = that.value(id, 'out'), partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points),
$player = Ox.VideoPlayer({ $player = Ox.VideoPlayer({
height: height, height: height,
'in': inPoint, 'in': partsAndPoints.points[0],
out: outPoint, out: partsAndPoints.points[1],
paused: true, paused: true,
playInToOut: true, playInToOut: true,
poster: '/' + item + '/' + height + 'p' + that.value(id, 'in') + '.jpg', poster: '/' + item + '/' + height + 'p' + points[0] + '.jpg',
width: width, width: width,
video: Ox.range(result.data.parts).map(function(i) { video: partsAndPoints.parts.map(function(i) {
return '/' + item + '/96p' + (i + 1) + '.' + pandora.user.videoFormat return '/' + item + '/96p' + (i + 1) + '.' + pandora.user.videoFormat
}) })
}) })