Skip to content

Commit

Permalink
πŸ› amp-ima-video: Fix pause button jamming on autoplay (#34307)
Browse files Browse the repository at this point in the history
When autoplaying a video with a preroll ad, the pause button will not work the first time. This is because we haven't tracked the `PlayerState`. This change keeps track of `PlayerState` on ad events, as meant initially.
  • Loading branch information
alanorozco committed May 17, 2021
1 parent 8cb5da6 commit 809e46f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ads/google/ima/ima-video.js
Expand Up @@ -842,6 +842,7 @@ export function onContentPauseRequested(global) {
adsManagerHeightOnLoad = null;
}
adsActive = true;
playerState = PlayerStates.PLAYING;
postMessage({event: VideoEvents.AD_START});
toggle(elements['adContainer'], true);
showAdControls();
Expand Down Expand Up @@ -889,6 +890,7 @@ export function onContentResumeRequested() {
*/
export function onAdPaused() {
toggleRootDataAttribute('playing', false);
playerState = PlayerStates.PAUSE;
}

/**
Expand All @@ -900,6 +902,7 @@ export function onAdPaused() {
*/
export function onAdResumed() {
toggleRootDataAttribute('playing', true);
playerState = PlayerStates.PLAYING;
}

/**
Expand Down

0 comments on commit 809e46f

Please sign in to comment.