Skip to content

Commit

Permalink
Hide the poster when play fires. closes #1834
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlap committed Feb 9, 2015
1 parent 42fbd4c commit f980cdb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CHANGELOG
* @mmcc added a VERSION key to the videojs object ([view](https://github.com/videojs/video.js/pull/1798))
* @mmcc fixed an issue with text track hiding introduced in #1681 ([view](https://github.com/videojs/video.js/pull/1804))
* Export video.js as a named AMD module ([view](https://github.com/videojs/video.js/pull/1844))
* Hide the poster when play fires ([view](https://github.com/videojs/video.js/pull/1834))

--------------------

Expand Down
7 changes: 4 additions & 3 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,6 @@ vjs.Player.prototype.onLoadStart = function() {
} else {
// reset the hasStarted state
this.hasStarted(false);
this.one('play', function(){
this.hasStarted(true);
});
}
};

Expand Down Expand Up @@ -451,6 +448,10 @@ vjs.Player.prototype.onLoadedAllData;
vjs.Player.prototype.onPlay = function(){
this.removeClass('vjs-paused');
this.addClass('vjs-playing');

// hide the poster when the user hits play
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play
this.hasStarted(true);
};

/**
Expand Down
3 changes: 3 additions & 0 deletions test/unit/mediafaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ vjs.MediaFaker.prototype.volume = function(){ return 0; };
vjs.MediaFaker.prototype.muted = function(){ return false; };
vjs.MediaFaker.prototype.pause = function(){ return false; };
vjs.MediaFaker.prototype.paused = function(){ return true; };
vjs.MediaFaker.prototype.play = function() {
this.player().trigger('play');
};
vjs.MediaFaker.prototype.supportsFullScreen = function(){ return false; };
vjs.MediaFaker.prototype.buffered = function(){ return {}; };
vjs.MediaFaker.prototype.duration = function(){ return {}; };
Expand Down
21 changes: 21 additions & 0 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,27 @@ test('should set and update the poster value', function(){
player.dispose();
});

// hasStarted() is equivalent to the "show poster flag" in the
// standard, for the purpose of displaying the poster image
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play
test('should hide the poster when play is called', function() {
var player = PlayerTest.makePlayer({
poster: 'https://example.com/poster.jpg'
});

equal(player.hasStarted(), false, 'the show poster flag is true before play');
player.play();
equal(player.hasStarted(), true, 'the show poster flag is false after play');

player.trigger('loadstart');
equal(player.hasStarted(),
false,
'the resource selection algorithm sets the show poster flag to true');

player.play();
equal(player.hasStarted(), true, 'the show poster flag is false after play');
});

test('should load a media controller', function(){
var player = PlayerTest.makePlayer({
preload: 'none',
Expand Down

0 comments on commit f980cdb

Please sign in to comment.