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 amp-audio on the first page of a story. #21611

Merged
merged 4 commits into from Mar 29, 2019

Conversation

gmajoulet
Copy link
Contributor

Using an amp-audio element on the first page of a story has two issues:

  • Playing the audio will fail since there was no user intent, and trigger the "Play this video" UI message that's supposed to be for videos only -> we stop triggering this message, and rely on the story unmute button to play the audio
  • Unmuting the story will unmute the audio, but not play it -> play the audio if it wasn't playing when it's unmuted

Fixes #21604

mediaEl = /** @type {!./media-pool.DomElementDef} */ (mediaEl);
const promises = [mediaPool.unmute(mediaEl)];

// Audio element on the first page of a story would not be playing since
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it's not necessarily just the first page, it could potentially be any page where the browser has rejected playback for whatever reason. Not sure if it's worth trying to message that here, for future readers

extensions/amp-story/1.0/amp-story-page.js Show resolved Hide resolved
@gmajoulet
Copy link
Contributor Author

PTAL

@gmajoulet
Copy link
Contributor Author

PTAL

extensions/amp-story/1.0/media-pool.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/amp-story-page.js Outdated Show resolved Hide resolved
@danielrozenberg danielrozenberg removed their request for review March 29, 2019 15:35
Copy link
Contributor Author

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

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

I changed the code so it respects the "loop" attribute. We don't want to play a 5s video after 10s on the page.

extensions/amp-story/1.0/media-pool.js Outdated Show resolved Hide resolved
@gmajoulet gmajoulet merged commit 3563c96 into ampproject:master Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants