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-9262): playback doesn't return to start after playback with ads in LG TV #79

Merged
merged 7 commits into from
Jul 28, 2019
Merged
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
31 changes: 21 additions & 10 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
* @private
*/
_shaka: any;
/**
* attached the media events after attachMediaSource
* @member {boolean} _isMediaAttached
* @private
*/
_isMediaAttached: boolean = false;
/**
* an object containing all the events we bind and unbind to.
* @member {Object} - _adapterEventsBindings
Expand Down Expand Up @@ -323,6 +329,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
this._shaka = new shaka.Player(this._videoElement);
this._maybeSetDrmConfig();
this._shaka.configure(this._config.shakaConfig);
this._isMediaAttached = true;
this._addBindings();
}

Expand Down Expand Up @@ -411,23 +418,26 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
/**
* attach media - return the media source to handle the video tag
* @public
* @param {boolean} playbackEnded playback ended after ads and media
* @returns {void}
*/
attachMediaSource(playbackEnded: ?boolean): void {
if (!this._shaka) {
attachMediaSource(): void {
if (!this._isMediaAttached) {
if (this._videoElement && this._videoElement.src) {
Utils.Dom.setAttribute(this._videoElement, 'src', '');
Utils.Dom.removeAttribute(this._videoElement, 'src');
}
this._init();
if (!isNaN(this._lastTimeDetach) && !playbackEnded) {
const canPlayHandler = () => {
const _seekAfterDetach = () => {
if (parseInt(this._lastTimeDetach) === parseInt(this.duration)) {
this.currentTime = 0;
} else {
this.currentTime = this._lastTimeDetach;
this._lastTimeDetach = NaN;
};
this._eventManager.listenOnce(this._videoElement, EventType.CAN_PLAY, canPlayHandler);
}
this._lastTimeDetach = NaN;
};
if (!isNaN(this._lastTimeDetach)) {
this._eventManager.listenOnce(this._videoElement, EventType.LOADED_DATA, () => _seekAfterDetach());
}
this._isMediaAttached = true;
}
}
/**
Expand All @@ -436,7 +446,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
* @returns {void}
*/
detachMediaSource(): void {
if (this._shaka) {
if (this._isMediaAttached) {
this._lastTimeDetach = this.currentTime;
this._reset().then(() => {
this._shaka = null;
Expand Down Expand Up @@ -567,6 +577,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
this._buffering = false;
this._waitingSent = false;
this._playingSent = false;
this._isMediaAttached = false;
this._clearVideoUpdateTimer();
if (this._eventManager) {
this._eventManager.removeAll();
Expand Down