From 11b93013373411704cd10751236692d197f4c824 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 1 May 2013 12:34:07 +0000 Subject: [PATCH] fix changing resolution for multi part videos, fixes #1491 --- source/Ox.UI/js/Video/VideoElement.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/source/Ox.UI/js/Video/VideoElement.js b/source/Ox.UI/js/Video/VideoElement.js index 35cee274..ec012ab6 100644 --- a/source/Ox.UI/js/Video/VideoElement.js +++ b/source/Ox.UI/js/Video/VideoElement.js @@ -253,7 +253,9 @@ Ox.VideoElement = function(options, self) { if (self.video) { self.$video.hide(); self.video.pause(); - self.video.currentTime = 0; + if(self.video.readyState >= self.video.HAVE_METADATA) { + self.video.currentTime = 0; + } volume = self.video.volume; muted = self.video.muted; } @@ -429,14 +431,22 @@ Ox.VideoElement = function(options, self) { src get/set source @*/ that.src = function() { - var ret; + var ret, src; if (arguments.length == 0) { ret = self.video.src; } else { self.options.src = Ox.isArray(arguments[0]) ? arguments[0] : [arguments[0]]; if (self.loadedMetadata) { - self.$video[self.currentPart].src = self.options.src[self.currentPart]; - self.$video.each(function(i, video) { + console.log(self.currentPart, self.$video[self.currentPart], self.$video); + //fixme: get rid of this to make use of browser caching + // but in all browsers except firefox, + // loadedmetadata fires only once per src + src = self.options.src[self.currentPart]; + if (src.length > 0 && Ox.startsWith(Ox.parseURL(src).protocol, 'http')) { + src += '?' + Ox.uid(); + } + self.$video[0].src = src; + self.items[0].$videos.forEach(function($video, i) { if (i != self.currentPart) { var src = self.options.src[i]; //fixme: get rid of this to make use of browser caching @@ -445,7 +455,7 @@ Ox.VideoElement = function(options, self) { if (src.length > 0 && Ox.startsWith(Ox.parseURL(src).protocol, 'http')) { src += '?' + Ox.uid(); } - video.src = src; + $video[0].src = src; } }); } else {