Tests which autoplay scenarios are allowed or blocked based on the current
mediaTypesRequiringUserActionForPlayback configuration.
Each test creates a media element and attempts to play it without user interaction.
A <video> element with muted autoplay. Most browsers allow this by default.
A <video> element with autoplay (not muted). Browsers with audio blocking will reject this.
An <audio> element with autoplay. Should be blocked when audio autoplay is blocked.
A muted <video> element with play() called from script (no autoplay attribute).
An unmuted <video> element with play() called from script.
Based on the WKAudiovisualMediaTypes value set on
WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback.
| Test | [] (allow all) | .audio | .all |
|---|---|---|---|
| 1. Muted video | Allowed | Allowed | Allowed* |
| 2. Unmuted video | Allowed | Blocked | Blocked |
| 3. Audio element | Allowed | Blocked | Blocked |
| 4. play() muted | Allowed | Allowed | Blocked |
| 5. play() unmuted | Allowed | Blocked | Blocked |
* WebKit exempts muted video with the autoplay attribute
from restrictions regardless of configuration. Programmatic play()
on muted video (test 4) is still blocked under .all.