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