load less videos per clip
This commit is contained in:
parent
a815b3119e
commit
5b49168890
2 changed files with 26 additions and 17 deletions
|
@ -144,17 +144,26 @@ pandora.getListData = function() {
|
|||
return data;
|
||||
};
|
||||
|
||||
pandora.getVideoPartAndPosition = function(durations, position) {
|
||||
var duration = 0, ret;
|
||||
Ox.forEach(durations, function(d, i) {
|
||||
if (duration + d > position) {
|
||||
ret = {
|
||||
part: i,
|
||||
position: position - duration
|
||||
pandora.getVideoPartsAndPoints = function(durations, points) {
|
||||
var parts = durations.length,
|
||||
offsets = Ox.range(parts).map(function(i) {
|
||||
return Ox.sum(Ox.sub(durations, 0, i));
|
||||
}),
|
||||
ret = {
|
||||
parts: [],
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -233,18 +233,18 @@ pandora.ui.list = function() { // fixme: remove view argument
|
|||
if ($img.length) {
|
||||
var width = parseInt($img.css('width')),
|
||||
height = parseInt($img.css('height'));
|
||||
pandora.api.get({id: item, keys: ['parts']}, function(result) {
|
||||
var inPoint = that.value(id, 'in'),
|
||||
outPoint = that.value(id, 'out'),
|
||||
pandora.api.get({id: item, keys: ['durations']}, function(result) {
|
||||
var points = [that.value(id, 'in'), that.value(id, 'out')],
|
||||
partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points),
|
||||
$player = Ox.VideoPlayer({
|
||||
height: height,
|
||||
'in': inPoint,
|
||||
out: outPoint,
|
||||
'in': partsAndPoints.points[0],
|
||||
out: partsAndPoints.points[1],
|
||||
paused: true,
|
||||
playInToOut: true,
|
||||
poster: '/' + item + '/' + height + 'p' + that.value(id, 'in') + '.jpg',
|
||||
poster: '/' + item + '/' + height + 'p' + points[0] + '.jpg',
|
||||
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
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue