Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-7355): don't show poster when autoplaying is on #158

Merged
merged 6 commits into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
background-color: #000;
}

.playkit-subtitles {
Expand Down
6 changes: 4 additions & 2 deletions src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,9 @@ export default class Player extends FakeEventTarget {
}
if (this._selectEngineByPriority()) {
this._appendEngineEl();
this._posterManager.setSrc(this._config.metadata.poster);
Copy link
Contributor

@dan-ziv dan-ziv Nov 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to set the source anyway, whether if we will hide it or show it later.

this._posterManager.show();
this._attachMedia();
this._handlePlaybackOptions();
this._posterManager.setSrc(this._config.metadata.poster);
this._handleAutoPlay();
if (receivedSourcesWhenHasEngine) {
Player._logger.debug('Change source ended');
Expand Down Expand Up @@ -1280,13 +1279,16 @@ export default class Player extends FakeEventTarget {
this.dispatchEvent(new FakeEvent(CustomEvents.FALLBACK_TO_MUTED_AUTOPLAY));
} else {
Player._logger.warn("Autoplay failed, pause player");
this._posterManager.show();
this.load();
this.ready().then(() => this.pause());
this.dispatchEvent(new FakeEvent(CustomEvents.AUTOPLAY_FAILED));
}
}
});
}
} else {
this._posterManager.show();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/poster-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class PosterManager {
setSrc(posterUrl: ?string): void {
if (posterUrl) {
this._posterUrl = posterUrl;
Utils.Dom.setStyle(this._el, "background-color", "black");
Utils.Dom.setStyle(this._el, "background-image", `url("${this._posterUrl}")`);
this.hide();
}
}

Expand Down