From 079114c59896042d984ea9f65977237f47a4022e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 13 Jul 2013 23:06:44 +0000 Subject: [PATCH] support updating video --- source/Ox.UI/js/Video/VideoPlayer.js | 55 ++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/source/Ox.UI/js/Video/VideoPlayer.js b/source/Ox.UI/js/Video/VideoPlayer.js index 8494cc59..866ac611 100644 --- a/source/Ox.UI/js/Video/VideoPlayer.js +++ b/source/Ox.UI/js/Video/VideoPlayer.js @@ -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) {