WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
259925
HTMLMediaElement.play() doesn't work if gesture/event handler is asynchronous
https://bugs.webkit.org/show_bug.cgi?id=259925
Summary
HTMLMediaElement.play() doesn't work if gesture/event handler is asynchronous
Jamie W
Reported
2023-08-08 03:23:17 PDT
Like other browsers, Safari uses gesture-tracking to determine whether or not a call to HTMLMediaElement.play() should be allowed, if the website is not permitted to autoplay. However, unlike other browser engines, Safari will only permit the play() call from the synchronous scope of an event handler. Consequently it is not possible to implement asynchronous handling of playback. I would say that most websites with unwanted autoplay videos already use the first gesture on the page to trigger playback - so implementing this in Safari wouldn't lead to a more 'annoying' internet experience. Although many developers are working around this bug by calling .play() synchronously from the gesture event handler, then changing its 'src' attribute as a result of some asynchronous action, this doesn't seem to work when using MediaSource extensions, as attaching a new MediaSource seems to reset its autoplay state. Indeed there are many legitimate use cases on the web where this sort of behaviour is desired, so I would be grateful if you could consider adopting the same behaviour as other browsers. This bug in particular is preventing us from being able to support Mobile Safari in our multi-track editor - where multiple audio files are loaded from a remote location and triggered in sequence from a single "Play" button.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2023-08-15 03:24:14 PDT
<
rdar://problem/113898637
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug