forked from 0x2620/oxjs
handle video formats and resolutions
This commit is contained in:
parent
c5bde89971
commit
ba96bfb76c
5 changed files with 45 additions and 16 deletions
|
|
@ -31,8 +31,7 @@ Ox.VideoEditor = function(options, self) {
|
|||
showAnnotations: false,
|
||||
showLargeTimeline: true,
|
||||
subtitles: [],
|
||||
videoHeight: 0,
|
||||
videoWidth: 0,
|
||||
videoRatio: 16/9,
|
||||
videoSize: 'small',
|
||||
video: '',
|
||||
width: 0
|
||||
|
|
@ -140,7 +139,6 @@ Ox.VideoEditor = function(options, self) {
|
|||
$timeline: [],
|
||||
controlsHeight: 16,
|
||||
margin: 8,
|
||||
videoRatio: self.options.videoWidth / self.options.videoHeight
|
||||
});
|
||||
|
||||
self.words = [];
|
||||
|
|
@ -772,7 +770,7 @@ Ox.VideoEditor = function(options, self) {
|
|||
left: (i + 0.5) * self.margin + width,
|
||||
top: self.margin / 2,
|
||||
width: widths[i],
|
||||
height: Math.round(widths[1] / self.videoRatio)
|
||||
height: Math.round(widths[1] / self.options.videoRatio)
|
||||
};
|
||||
width += widths[i];
|
||||
});
|
||||
|
|
@ -780,15 +778,15 @@ Ox.VideoEditor = function(options, self) {
|
|||
size.player[0] = {
|
||||
left: self.margin / 2,
|
||||
top: self.margin / 2,
|
||||
width: Math.round((contentWidth - 3 * self.margin + (self.controlsHeight + self.margin) / 2 * self.videoRatio) * 2/3),
|
||||
width: Math.round((contentWidth - 3 * self.margin + (self.controlsHeight + self.margin) / 2 * self.options.videoRatio) * 2/3),
|
||||
};
|
||||
size.player[0].height = Math.round(size.player[0].width / self.videoRatio);
|
||||
size.player[0].height = Math.round(size.player[0].width / self.options.videoRatio);
|
||||
size.player[1] = {
|
||||
left: size.player[0].left + size.player[0].width + self.margin,
|
||||
top: size.player[0].top,
|
||||
width: contentWidth - 3 * self.margin - size.player[0].width
|
||||
};
|
||||
size.player[1].height = Math.ceil(size.player[1].width / self.videoRatio);
|
||||
size.player[1].height = Math.ceil(size.player[1].width / self.options.videoRatio);
|
||||
size.player[2] = {
|
||||
left: size.player[1].left,
|
||||
top: size.player[0].top + size.player[1].height + self.controlsHeight + self.margin,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ Ox.VideoElement = function(options, self) {
|
|||
setCurrentPart(self.currentPart + 1);
|
||||
self.video.play();
|
||||
} else {
|
||||
self.ended = true;
|
||||
self.paused = true;
|
||||
that.triggerEvent('ended');
|
||||
}
|
||||
},
|
||||
|
|
@ -89,7 +91,6 @@ Ox.VideoElement = function(options, self) {
|
|||
}
|
||||
|
||||
function setCurrentPart(part) {
|
||||
Ox.print('sCP', part)
|
||||
var css = {};
|
||||
['left', 'top', 'width', 'height'].forEach(function(key) {
|
||||
css[key] = self.$video.css(key);
|
||||
|
|
@ -130,6 +131,7 @@ Ox.VideoElement = function(options, self) {
|
|||
|
||||
that.currentTime = function() {
|
||||
var ret;
|
||||
self.ended = false;
|
||||
if (arguments.length == 0) {
|
||||
ret = getCurrentTime();
|
||||
} else {
|
||||
|
|
@ -159,6 +161,10 @@ Ox.VideoElement = function(options, self) {
|
|||
};
|
||||
|
||||
that.play = function() {
|
||||
if (self.ended) {
|
||||
that.currentTime(0);
|
||||
self.ended = false;
|
||||
}
|
||||
self.paused = false;
|
||||
self.video.play();
|
||||
return that;
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ Ox.VideoPanelPlayer = function(options, self) {
|
|||
showControls: true,
|
||||
subtitles: [],
|
||||
video: '',
|
||||
videoHeight: 0,
|
||||
videoWidth: 0,
|
||||
volume: 1,
|
||||
width: 0
|
||||
})
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ Ox.VideoPlayer = function(options, self) {
|
|||
.options(options || {})
|
||||
.addClass('OxVideoPlayer');
|
||||
|
||||
Ox.print('VIDEO PLAYER OPTIONS', self.options)
|
||||
|
||||
Ox.UI.$window.bind({
|
||||
resize: function() {
|
||||
self.options.fullscreen && setSizes();
|
||||
|
|
@ -133,14 +135,11 @@ Ox.VideoPlayer = function(options, self) {
|
|||
if (Ox.isString(self.options.video)) {
|
||||
self.video = self.options.video;
|
||||
} else {
|
||||
/*
|
||||
self.resolutions = Ox.sort(Object.keys(self.options.video));
|
||||
if (!(self.options.resolution in self.options.video)) {
|
||||
self.options.resolution = self.resolutions[0];
|
||||
}
|
||||
self.video = self.options.video[self.options.resolution];
|
||||
*/
|
||||
self.video = self.options.video(self.options.resolution, self.options.format)
|
||||
}
|
||||
|
||||
if (self.options.playInToOut) {
|
||||
|
|
@ -238,12 +237,12 @@ Ox.VideoPlayer = function(options, self) {
|
|||
mouseenter: function() {
|
||||
showControls();
|
||||
self.mouseHasLeft = false;
|
||||
Ox.print('MOUSE HAS ENTERED')
|
||||
//Ox.print('MOUSE HAS ENTERED')
|
||||
},
|
||||
mouseleave: function() {
|
||||
hideControls();
|
||||
self.mouseHasLeft = true;
|
||||
Ox.print('MOUSE HAS LEFT')
|
||||
//Ox.print('MOUSE HAS LEFT')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue