From 0ba71666363d5a519e44b44e974d1bf0f6a40b18 Mon Sep 17 00:00:00 2001 From: David LaPalomento Date: Thu, 7 Mar 2013 20:57:52 -0500 Subject: [PATCH 1/2] Fixes #367 If you are quick, you could get videojs to wrap the HTML video element twice on iOS. The video element has to be recreated after moving on iOS but we weren't re-associating it with the player object. When autoSetup swung through, it would re-initialize the video element and create a player within a player. --- src/js/component.js | 2 +- src/js/media.html5.js | 3 +++ test/unit/media.html5.js | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/js/component.js b/src/js/component.js index 3deb4bb68..97f4dbf43 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -23,7 +23,7 @@ vjs.Component = function(player, options, ready){ this.name_ = options['name'] || null; - // Create element if one wasn't provided in potions + // Create element if one wasn't provided in options this.el_ = options['el'] || this.createEl(); this.children_ = []; diff --git a/src/js/media.html5.js b/src/js/media.html5.js index 4a63a8320..5b2ad108b 100644 --- a/src/js/media.html5.js +++ b/src/js/media.html5.js @@ -68,6 +68,9 @@ vjs.Html5.prototype.createEl = function(){ className:'vjs-tech' }); } + // associate the player with the new tag + el['player'] = player; + vjs.insertFirst(el, player.el()); } diff --git a/test/unit/media.html5.js b/test/unit/media.html5.js index b89f00256..df410b9d6 100644 --- a/test/unit/media.html5.js +++ b/test/unit/media.html5.js @@ -16,3 +16,22 @@ test('should detect whether the volume can be changed', function(){ ok(!vjs.Html5.canControlVolume()); vjs.TEST_VID = testVid; }); + +test('should re-link the player if the tech is moved', function(){ + var player, tech, el; + el = document.createElement('div'); + el.innerHTML = '
'; + player = { + id: function(){ return 'id'; }, + el: function(){ return el; }, + options_: {}, + ready: function(){} + }; + tech = new vjs.Html5(player, {}); + tech.features = { + movingMediaElementInDOM: false + }; + tech.createEl(); + + strictEqual(player, tech.el().player); +}); \ No newline at end of file From 7e0ee0c799365103891fc9f35755bf8d038d57fb Mon Sep 17 00:00:00 2001 From: David LaPalomento Date: Fri, 8 Mar 2013 10:13:01 -0500 Subject: [PATCH 2/2] Fix minified property access Use a string literal to reference the tech's player property so the access isn't mangled by closure. --- test/unit/media.html5.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/media.html5.js b/test/unit/media.html5.js index df410b9d6..a3c1698d6 100644 --- a/test/unit/media.html5.js +++ b/test/unit/media.html5.js @@ -33,5 +33,5 @@ test('should re-link the player if the tech is moved', function(){ }; tech.createEl(); - strictEqual(player, tech.el().player); + strictEqual(player, tech.el()['player']); }); \ No newline at end of file