support updating video

This commit is contained in:
j 2013-07-13 23:06:44 +00:00
parent 2403cd269d
commit 079114c598

View file

@ -217,6 +217,15 @@ Ox.VideoPlayer = function(options, self) {
sizeIsLarge: function() { sizeIsLarge: function() {
self.$sizeButton.toggle(); self.$sizeButton.toggle();
}, },
timeline: function() {
self.$timeline.options({imageURL: self.options.timeline});
},
video: function() {
setVideo();
self.$video.options({
items: self.video
});
},
volume: function() { volume: function() {
setVolume(self.options.volume); setVolume(self.options.volume);
}, },
@ -243,16 +252,7 @@ Ox.VideoPlayer = function(options, self) {
self.options.annotations = self.options.subtitles; self.options.annotations = self.options.subtitles;
} }
if (Ox.isObject(self.options.video)) { setVideo();
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];
} else {
self.isPlaylist = Ox.isFunction(self.options.video);
self.video = self.options.video;
}
if (self.options.playInToOut) { if (self.options.playInToOut) {
self['in'] = self.options['in']; self['in'] = self.options['in'];
@ -410,6 +410,7 @@ Ox.VideoPlayer = function(options, self) {
} : {}*/) } : {}*/)
) )
.bindEvent(Ox.extend({ .bindEvent(Ox.extend({
durationchange: durationchange,
ended: ended, ended: ended,
loadedmetadata: loadedmetadata, loadedmetadata: loadedmetadata,
itemchange: itemchange, itemchange: itemchange,
@ -1252,6 +1253,15 @@ Ox.VideoPlayer = function(options, self) {
function dragend() { function dragend() {
!self.drag.paused && togglePaused(); !self.drag.paused && togglePaused();
} }
function durationchange() {
self.out = self.options.playInToOut && self.out < self.$video.duration()
? self.out : self.$video.duration();
self.options.duration = self.out - self['in'];
self.$timeline && self.$timeline.replaceWith(
self.$timeline = getTimeline()
);
}
function ended() { function ended() {
if (self.options.loop) { if (self.options.loop) {
@ -1800,10 +1810,12 @@ Ox.VideoPlayer = function(options, self) {
? self.out : self.$video.duration(); ? self.out : self.$video.duration();
self.options.duration = self.out - self['in']; self.options.duration = self.out - self['in'];
Ox.Log('Video', '---------------------------------------- POS', self.options.position) Ox.Log('Video', '---------------------------------------- POS', self.options.position)
Ox.Log('Video', '----------------------------------- DURATION', self.options.duration)
//self.options.position = Ox.limit(self.options.position, self['in'], self.out); //self.options.position = Ox.limit(self.options.position, self['in'], self.out);
//self.$video.currentTime(self.options.position); //self.$video.currentTime(self.options.position);
!self.isPlaylist && setPosition(self.options.position); setPosition(self.options.position);
self.$video.muted(self.options.muted).volume(self.options.volume); self.$video.muted(self.options.muted).volume(self.options.volume);
if (!self.options.paused) { if (!self.options.paused) {
@ -1823,7 +1835,6 @@ Ox.VideoPlayer = function(options, self) {
}, 250); }, 250);
} }
} }
!hadDuration && self.$timeline && self.$timeline.replaceWith( !hadDuration && self.$timeline && self.$timeline.replaceWith(
self.$timeline = getTimeline() self.$timeline = getTimeline()
); );
@ -1853,9 +1864,7 @@ Ox.VideoPlayer = function(options, self) {
(self.playInToOut && self.options.position >= self.options.out) (self.playInToOut && self.options.position >= self.options.out)
|| (self.options.playInToOut && self.options.position >= self.out) || (self.options.playInToOut && self.options.position >= self.out)
) { ) {
if (self.isPlaylist) { if (self.options.loop) {
self.$video.playNext();
} else if (self.options.loop) {
rewind(); rewind();
self.$video.play(); self.$video.play();
} else { } else {
@ -2124,8 +2133,9 @@ Ox.VideoPlayer = function(options, self) {
} }
self.loadedMetadata = false; self.loadedMetadata = false;
showLoadingIcon(); showLoadingIcon();
self.video = self.options.video[self.options.resolution];
self.$video.options({ self.$video.options({
items: self.options.video[self.options.resolution] items: self.video
}); });
self.$playButton && self.$playButton.options({disabled: true}); self.$playButton && self.$playButton.options({disabled: true});
that.triggerEvent('resolution', { that.triggerEvent('resolution', {
@ -2220,6 +2230,19 @@ Ox.VideoPlayer = function(options, self) {
that.triggerEvent('timeline', {timeline: self.options.timelineType}); that.triggerEvent('timeline', {timeline: self.options.timelineType});
} }
function setVideo() {
if (Ox.isObject(self.options.video)) {
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];
} else {
self.video = self.options.video;
}
}
function setVolume(volume) { function setVolume(volume) {
self.options.volume = volume; self.options.volume = volume;
if (!!self.options.volume == self.options.muted) { if (!!self.options.volume == self.options.muted) {