1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-25 11:13:52 +02:00

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.
This commit is contained in:
David LaPalomento 2013-04-04 09:55:27 -04:00
parent 6bd4651767
commit 99a973e529
3 changed files with 19 additions and 2 deletions

View File

@ -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 <img>
tag.removeAttribute('poster');
// Remove width/height attrs from tag so CSS can make it 100% width/height
tag.removeAttribute('width');
tag.removeAttribute('height');

View File

@ -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());

View File

@ -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',