1
0
Fork 0
forked from 0x2620/oxjs

updating video elements (fixes bugs with positions and points)

This commit is contained in:
rlx 2011-09-17 07:09:17 +00:00
commit 3f90e96c3a
6 changed files with 44 additions and 24 deletions

View file

@ -42,7 +42,7 @@ Ox.VideoPlayer <f> Generic Video Player
poster <s|''> Poster URL
posterFrame <n|-1> Position of poster frame (sec)
preload <s|'auto'> 'auto', 'metadata' or 'none'
out <n|-1> Out point (sec)
out <n> Out point (sec)
resolution <n|0> resolution
scaleToFill <b|false> If true, scale to fill (otherwise, scale to fit)
showControlsOnLoad <b|false> If true, show controls on load
@ -150,7 +150,7 @@ Ox.VideoPlayer = function(options, self) {
self.options.duration = self.out - self['in'];
} else {
self['in'] = 0;
self.out = self.options.duration || 86399;
self.out = self.options.duration || 86399; // fixme: ugly
}
self.options.position = Ox.limit(self.options.position, self['in'], self.out);
@ -1446,12 +1446,20 @@ Ox.VideoPlayer = function(options, self) {
self.$video
.one({
load: function() {
Ox.print('IMAGE LOADED', self.options.video(self.options.position, self.options.width))
hideLoadingIcon();
}
})
.attr({
src: self.options.video(self.options.position, self.options.width)
src: self.options.video(
// fixme: this keeps the frame from being beyond the end,
// but what should be avoided is setting position to a point
// beyond the beginning of the last frame
Math.min(
self.options.position,
Math.floor(self.options.duration * self.options.fps) / self.options.fps
),
self.options.width
)
});
}
@ -1473,9 +1481,8 @@ Ox.VideoPlayer = function(options, self) {
marker.css(self.posterMarkerCSS[position]);
});
self.out = self.options.playInToOut &&
self.out < self.$video.duration() ?
self.out : self.$video.duration();
self.out = self.options.playInToOut && self.out < self.$video.duration()
? self.out : self.$video.duration();
self.options.duration = self.out - self['in'];
Ox.print('---------------------------------------- POS', self.options.position)
//self.options.position = Ox.limit(self.options.position, self['in'], self.out);
@ -1533,14 +1540,14 @@ Ox.VideoPlayer = function(options, self) {
function playing() {
self.options.position = self.$video.currentTime();
if (
(self.options.playInToOut || self.playInToOut || self.isPlaylist) &&
self.options.position >= self.out
) {
(self.playInToOut && self.options.position >= self.options.out)
|| (self.options.playInToOut && self.options.position >= self.out)
) {
if (self.isPlaylist) {
self.$video.playNext();
} else {
togglePaused();
setPosition(self.out/*, 'video'*/);
setPosition(self.playInToOut ? self.options.out : self.out/*, 'video'*/);
//ended();
self.playInToOut = false;
}
@ -1554,7 +1561,6 @@ Ox.VideoPlayer = function(options, self) {
function playInToOut() {
if (self.options.out > self.options['in']) {
Ox.print('inToOut', self.options['in'])
self.playInToOut = true;
setPosition(self.options['in']);
self.options.paused && togglePaused();