ampproject / ampproject/amphtml

Skip video blessing if autoplaying media with sound is allowed

Open
#27,750 1 comment 0 reactions 1 assignee Assigned to @gmajoulet View on GitHub
P1: High Priority Stale Type: Feature Request WG: stories
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

To work around the fact that web browsers block autoplaying media with sound, we use the click event on the unmute button to unmute + mute back all the media elements, which allows us to autoplay them with sound later on. We call this process "blessing" the media elements. But media operations take time on iOS, and apparently block the main thread for a significant enough amount of time.

However, native webviews can allow autoplaying media with sound. We should try to detect if videos can be autoplayed with sound, and skip the entire expensive blessing process if so.

We should be able to adapt and re-use this piece of code:
https://github.com/ampproject/amphtml/blob/9cc61e6bdd1b218aafe65c81dc382f3751797f38/src/utils/video.js#L93-L98

cc @ampproject/wg-stories

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.