don't use canvas for the timeline image
This commit is contained in:
parent
bab9c8be8e
commit
aadd8c8458
2 changed files with 44 additions and 64 deletions
|
@ -53,14 +53,11 @@ Ox.BlockVideoTimeline = function(options, self) {
|
||||||
timeline: self.options.timeline,
|
timeline: self.options.timeline,
|
||||||
width: Math.ceil(self.options.duration),
|
width: Math.ceil(self.options.duration),
|
||||||
type: self.options.type
|
type: self.options.type
|
||||||
})
|
});
|
||||||
.bindEvent('load', function() {
|
|
||||||
// wait until the timeline image (the one image that is async)
|
Ox.loop(self.lines, function(i) {
|
||||||
// has loaded, so we can clone the element
|
addLine(i);
|
||||||
Ox.loop(self.lines, function(i) {
|
});
|
||||||
addLine(i);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
self.$positionMarker = $('<img>')
|
self.$positionMarker = $('<img>')
|
||||||
.attr({
|
.attr({
|
||||||
|
|
|
@ -24,8 +24,11 @@ Ox.SmallVideoTimelineImage = function(options, self) {
|
||||||
// fixme: timeline doesn't have to go through canvas at all,
|
// fixme: timeline doesn't have to go through canvas at all,
|
||||||
// just use one or more images
|
// just use one or more images
|
||||||
|
|
||||||
|
self.images = Ox.isString(self.options.timeline) ?
|
||||||
|
1 : Math.ceil(self.options.duration / 3600);
|
||||||
|
self.imageWidth = Ox.isString(self.options.timeline) ?
|
||||||
|
1920 : Math.round(self.options.duration);
|
||||||
self.height = self.options.type == 'player' ? 16 : 24;
|
self.height = self.options.type == 'player' ? 16 : 24;
|
||||||
self.imageWidth = Ox.isString(self.options.timeline) ? 1920 : Math.round(self.options.duration);
|
|
||||||
self.imageHeight = self.options.type == 'player' ? 16 : 18;
|
self.imageHeight = self.options.type == 'player' ? 16 : 18;
|
||||||
self.imageTop = self.options.type == 'player' ? 0 : 3;
|
self.imageTop = self.options.type == 'player' ? 0 : 3;
|
||||||
|
|
||||||
|
@ -33,24 +36,34 @@ Ox.SmallVideoTimelineImage = function(options, self) {
|
||||||
height: self.height + 'px'
|
height: self.height + 'px'
|
||||||
});
|
});
|
||||||
|
|
||||||
self.$timeline = $('<img>')
|
if (Ox.isString(self.options.timeline)) {
|
||||||
.attr({
|
self.$timeline = $('<img>')
|
||||||
src: Ox.UI.PATH + 'png/transparent.png'
|
.attr({
|
||||||
})
|
src: self.options.timeline
|
||||||
.css({
|
})
|
||||||
position: 'absolute',
|
.css({
|
||||||
width: self.options.width + 'px',
|
position: 'absolute',
|
||||||
height: self.imageHeight + 'px',
|
top: self.imageTop + 'px',
|
||||||
top: self.imageTop + 'px'
|
width: self.options.width + 'px',
|
||||||
})
|
height: self.imageHeight + 'px',
|
||||||
.appendTo(that.$element);
|
})
|
||||||
|
.appendTo(that.$element);
|
||||||
getImageURL('timeline', function(imageURL) {
|
} else {
|
||||||
self.$timeline.attr({
|
Ox.loop(self.images, function(i) {
|
||||||
src: imageURL
|
$('<img>')
|
||||||
|
.attr({
|
||||||
|
src: self.options.timeline(i)
|
||||||
|
})
|
||||||
|
.css({
|
||||||
|
position: 'absolute',
|
||||||
|
left: (i * 3600) + 'px',
|
||||||
|
top: self.imageTop + 'px',
|
||||||
|
width: (i == self.images - 1 ? self.imageWidth % 3600 : 3600) + 'px',
|
||||||
|
height: self.imageHeight + 'px',
|
||||||
|
})
|
||||||
|
.appendTo(that.$element);
|
||||||
});
|
});
|
||||||
that.triggerEvent('load');
|
}
|
||||||
});
|
|
||||||
|
|
||||||
self.$subtitles = $('<img>')
|
self.$subtitles = $('<img>')
|
||||||
.attr({
|
.attr({
|
||||||
|
@ -58,9 +71,9 @@ Ox.SmallVideoTimelineImage = function(options, self) {
|
||||||
})
|
})
|
||||||
.css({
|
.css({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
top: self.imageTop + 'px',
|
||||||
width: self.options.width + 'px',
|
width: self.options.width + 'px',
|
||||||
height: self.imageHeight + 'px',
|
height: self.imageHeight + 'px'
|
||||||
top: self.imageTop + 'px'
|
|
||||||
})
|
})
|
||||||
.appendTo(that.$element);
|
.appendTo(that.$element);
|
||||||
|
|
||||||
|
@ -70,9 +83,9 @@ Ox.SmallVideoTimelineImage = function(options, self) {
|
||||||
})
|
})
|
||||||
.css({
|
.css({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
top: self.imageTop + 'px',
|
||||||
width: self.options.width + 'px',
|
width: self.options.width + 'px',
|
||||||
height: self.imageHeight + 'px',
|
height: self.imageHeight + 'px'
|
||||||
top: self.imageTop + 'px'
|
|
||||||
})
|
})
|
||||||
.appendTo(that.$element);
|
.appendTo(that.$element);
|
||||||
|
|
||||||
|
@ -82,9 +95,9 @@ Ox.SmallVideoTimelineImage = function(options, self) {
|
||||||
})
|
})
|
||||||
.css({
|
.css({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
top: self.imageTop + 'px',
|
||||||
width: self.options.width + 'px',
|
width: self.options.width + 'px',
|
||||||
height: self.imageHeight + 'px',
|
height: self.imageHeight + 'px'
|
||||||
top: self.imageTop + 'px'
|
|
||||||
})
|
})
|
||||||
.appendTo(that.$element);
|
.appendTo(that.$element);
|
||||||
|
|
||||||
|
@ -168,39 +181,9 @@ Ox.SmallVideoTimelineImage = function(options, self) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (image == 'timeline') {
|
|
||||||
var $image, counter, images,
|
|
||||||
top = self.options.type == 'player' ? 0 : 1;
|
|
||||||
if (Ox.isString(self.options.timeline)) {
|
|
||||||
$image = $('<img>')
|
|
||||||
.attr({
|
|
||||||
src: self.options.timeline
|
|
||||||
})
|
|
||||||
.load(function() {
|
|
||||||
context.drawImage($image[0], 0, top)
|
|
||||||
callback(canvas.toDataURL());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
counter = 0;
|
|
||||||
images = Math.ceil(self.options.duration / 3600);
|
|
||||||
Ox.loop(images, function(i) {
|
|
||||||
var $image = $('<img>')
|
|
||||||
.attr({
|
|
||||||
src: self.options.timeline(i)
|
|
||||||
})
|
|
||||||
.load(function() {
|
|
||||||
context.drawImage($image[0], i * 3600, top);
|
|
||||||
if (++counter == images) {
|
|
||||||
callback(canvas.toDataURL());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (image != 'timeline') {
|
|
||||||
context.putImageData(imageData, 0, 0);
|
|
||||||
return canvas.toDataURL();
|
|
||||||
}
|
}
|
||||||
|
context.putImageData(imageData, 0, 0);
|
||||||
|
return canvas.toDataURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPosition() {
|
function getPosition() {
|
||||||
|
|
Loading…
Reference in a new issue