From c714781aefd2aa0c61082074a1cb51905dc8bd1d Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Mon, 13 Feb 2012 16:59:57 -0800 Subject: [PATCH 1/3] Added translation of Flash URL to absolute URL. --- src/lib.js | 8 ++++++++ src/tech.js | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lib.js b/src/lib.js index ad00e897f..10cf3bc46 100644 --- a/src/lib.js +++ b/src/lib.js @@ -277,6 +277,14 @@ _V_.extend({ _V_.log("LocalStorage Error (VideoJS)", e); } } + }, + + // Get abosolute version of relative URL. Used to tell flash correct URL. + // http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue + getAbsoluteURL: function(url){ + return _V_.createElement('div', { + innerHTML: 'x' + }).firstChild.href; } }); diff --git a/src/tech.js b/src/tech.js index 912f64ce5..775c09123 100644 --- a/src/tech.js +++ b/src/tech.js @@ -301,7 +301,17 @@ _V_.flash = _V_.PlaybackTech.extend({ // If source was supplied pass as a flash var. if (source) { - flashVars.src = encodeURIComponent(source.src); + + // Check if absolute URL + var tempSrc = source.src; + if (!tempSrc.match(/^https?:\/\//)) { + // Convert to absolute URL. Flash hosted off-site needs an absolute URL. + tempSrc = _V_.getAbsoluteURL(tempSrc); + } + + _V_.log(tempSrc) + + flashVars.src = encodeURIComponent(tempSrc); } // Add placeholder to player div From e4723240b6fa19769fb7f16bc58c7217b9497ddc Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Mon, 13 Feb 2012 17:13:14 -0800 Subject: [PATCH 2/3] Made src() update URL to absolute also. --- src/lib.js | 13 ++++++++++--- src/tech.js | 15 ++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lib.js b/src/lib.js index 10cf3bc46..b11337477 100644 --- a/src/lib.js +++ b/src/lib.js @@ -282,9 +282,16 @@ _V_.extend({ // Get abosolute version of relative URL. Used to tell flash correct URL. // http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue getAbsoluteURL: function(url){ - return _V_.createElement('div', { - innerHTML: 'x' - }).firstChild.href; + + // Check if absolute URL + if (!url.match(/^https?:\/\//)) { + // Convert to absolute URL. Flash hosted off-site needs an absolute URL. + url = _V_.createElement('div', { + innerHTML: 'x' + }).firstChild.href; + } + + return url; } }); diff --git a/src/tech.js b/src/tech.js index 775c09123..cc9da14ab 100644 --- a/src/tech.js +++ b/src/tech.js @@ -301,17 +301,7 @@ _V_.flash = _V_.PlaybackTech.extend({ // If source was supplied pass as a flash var. if (source) { - - // Check if absolute URL - var tempSrc = source.src; - if (!tempSrc.match(/^https?:\/\//)) { - // Convert to absolute URL. Flash hosted off-site needs an absolute URL. - tempSrc = _V_.getAbsoluteURL(tempSrc); - } - - _V_.log(tempSrc) - - flashVars.src = encodeURIComponent(tempSrc); + flashVars.src = encodeURIComponent(_V_.getAbsoluteURL(source.src)); } // Add placeholder to player div @@ -471,6 +461,9 @@ _V_.flash = _V_.PlaybackTech.extend({ play: function(){ this.el.vjs_play(); }, pause: function(){ this.el.vjs_pause(); }, src: function(src){ + // Make sure source URL is abosolute. + src = _V_.getAbsoluteURL(src); + this.el.vjs_src(src); // Currently the SWF doesn't autoplay if you load a source later. From 6932c64a18b0acbd72fc8d8aec7a07822e4bda57 Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Mon, 13 Feb 2012 17:14:50 -0800 Subject: [PATCH 3/3] Adding line to CHANGELOG: Automatically converting URsource URL to absolute for Flash fallback. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 625c33f15..b18421674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +* Automatically converting URsource URL to absolute for Flash fallback. * Created new 'loadedalldata' event for when the source is completely downloaded * Improved player.destory(). Now removes elements and references. * Refactored API to be more immediately available.