RESOLVED INVALID 282053
"canplay" event is not fired on iOS for audio elements
https://bugs.webkit.org/show_bug.cgi?id=282053
Summary "canplay" event is not fired on iOS for audio elements
Iaroslav Angliuster
Reported 2024-10-24 10:58:06 PDT
Created attachment 473034 [details] .MP3 test file On iOS Safari (versions 17.6.1 and 18.0.1), the "canplay" event is not fired when attempting to load an audio element. This issue does not occur on desktop Safari version 18.0.1 (20619.1.26.31.7, 621+) running macOS Sequoia 15.0.1. Expected Behavior: The "canplay" event should be fired after enough of the audio file is loaded to start playback. Actual Behavior: On iOS Safari (17.6.1 and 18.0.1), the "canplay" event is not fired. As a workaround, I am currently using the "loadedmetadata" event instead. Steps to Reproduce: Open Safari on iOS version 17.6.1 or 18.0.1, load HTML Test Case (code below) Observe the events triggered when the audio element is loaded. HTML Test Case (wawa.mp3 in attachments): ``` <html> <body> <audio src="wawa.mp3"></audio> </body> <script> const audio = document.getElementsByTagName('audio')[0]; audio.addEventListener("canplay", () => { alert("canplay event fired"); // doesn't work on iOS 17/18 Safari }) audio.addEventListener("loadedmetadata", () => { alert("loadedmetadata event fired"); // works on iOS 17/18 Safari }) </script> </html> ``` p.s. Also this might be related - "HTMLAudioElement issues in iOS 17.4": https://forums.developer.apple.com/forums/thread/748001
Attachments
.MP3 test file (36.40 KB, audio/mpeg)
2024-10-24 10:58 PDT, Iaroslav Angliuster
no flags
Iaroslav Angliuster
Comment 1 2024-10-25 00:12:34 PDT
More OSs tested: iPadOS 17.7 - "canplay" event is being fired iOS 16.6.1 - "canplay" event is not being fired
Iaroslav Angliuster
Comment 2 2024-10-25 01:44:55 PDT
iOS 15.2 (simulator) - "canplay" event is not being fired
Iaroslav Angliuster
Comment 3 2024-10-26 09:02:10 PDT
Also tested other versions of iOS: iOS 10.3 - "canplay" event is not being fired iOS 11.3 - "canplay" event is not being fired iOS 12.4 - "canplay" event is not being fired iOS 13.6 - "canplay" event is not being fired iOS 14.5 - "canplay" event is not being fired It looks like this behaviour is consistent across many versions of iOS, but I can't find any documentation on why "loadeddata", "canplay" and "canplaythrough" aren't specifically fired only on the iOS version of Safari. I hope I can find documentation on this and close this bug
Jean-Yves Avenard [:jya]
Comment 4 2024-10-26 21:20:07 PDT
audible audio (or video) elements aren't allowed to autoplay. So unless there's a user gesture, the readyState will not move to greater value that HAVE_CURRENT_DATA and so `canplay` won't be fired. This behaviour isn't unique to Safari
Note You need to log in before you can comment on or make changes to this bug.