From 99a973e529ae8d969e10542d58af7205d14e13af Mon Sep 17 00:00:00 2001 From: David LaPalomento Date: Thu, 4 Apr 2013 09:55:27 -0400 Subject: [PATCH] Do not remove poster attribute when creating the player We use a div with a background image to simulate the poster image so that we can use a single poster implementation for flash and html. It may be desirable on some platforms to use the native poster image, however. On iPhones for instance, the simulated poster image covers up the native play button and can make it difficult to figure out where to touch to initiate playback. By keeping the poster attribute on the underlying video element, you can hide the simulated poster to get a native look-and-feel on that platform. --- src/js/player.js | 2 -- test/unit/mediafaker.js | 4 ++++ test/unit/player.js | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/js/player.js b/src/js/player.js index 15ad9372d..65d60d856 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -131,8 +131,6 @@ vjs.Player.prototype.createEl = function(){ // Original tag settings stored in options // now remove immediately so native controls don't flash. tag.removeAttribute('controls'); - // Poster will be handled by a manual - tag.removeAttribute('poster'); // Remove width/height attrs from tag so CSS can make it 100% width/height tag.removeAttribute('width'); tag.removeAttribute('height'); diff --git a/test/unit/mediafaker.js b/test/unit/mediafaker.js index 6381eef52..9ed7e4cf8 100644 --- a/test/unit/mediafaker.js +++ b/test/unit/mediafaker.js @@ -22,6 +22,10 @@ vjs.MediaFaker.prototype.createEl = function(){ var el = goog.base(this, 'createEl', 'div', { className: 'vjs-tech' }); + if (this.player_.poster_) { + // transfer the poster image to mimic HTML + el.poster = this.player_.poster_; + } vjs.insertFirst(el, this.player_.el()); diff --git a/test/unit/player.js b/test/unit/player.js index 1e0a08254..51540678c 100644 --- a/test/unit/player.js +++ b/test/unit/player.js @@ -181,6 +181,21 @@ test('should accept options from multiple sources and override in correct order' player.dispose(); }); +test('should transfer the poster attribute unmodified', function(){ + var tag, fixture, poster, player; + poster = 'http://example.com/poster.jpg'; + tag = PlayerTest.makeTag(); + tag.setAttribute('poster', poster); + fixture = document.getElementById('qunit-fixture'); + + fixture.appendChild(tag); + player = new vjs.Player(tag, { + 'techOrder': ['mediaFaker'] + }); + + equal(player.tech.el().poster, poster, 'the poster attribute should not be removed'); +}); + test('should load a media controller', function(){ var player = PlayerTest.makePlayer({ preload: 'none',