Web Audio API update on iOS

I documented a weird bug with web audio on iOS a while back:

On some pages of The Session, as well as the audio player for tunes (using the Web Audio API) there are also embedded YouTube videos (using the video element). Press play on the audio p…

I documented a weird bug with web audio on iOS a while back:

On some pages of The Session, as well as the audio player for tunes (using the Web Audio API) there are also embedded YouTube videos (using the video element). Press play on the audio player; no sound. Press play on the YouTube video; you get sound. Now go back to the audio player and suddenly you do get sound!

It’s almost like playing a video or audio element “kicks” the browser into realising it should be playing the sound from the Web Audio API too.

This was happening on iOS devices set to mute, but I was also getting reports of it happening on devices with the sound on. But it’s that annoyingly intermittent kind of bug that’s really hard to reproduce consistently. Sometimes the sound doesn’t play. Sometimes it does.

I found a workaround but it was really hacky. By playing a one-second long silent mp3 file using audio, you could “kick” the sound into behaving. Then you can use the Web Audio API and it would play consistently.

Well, that’s all changed with the latest release of Mobile Safari. Now what happens is that the Web Audio stuff plays …for one second. And then stops.

I removed the hacky workaround and the Web Audio API started behaving itself again …but your device can’t be set to silent.

The good news is that the Web Audio behaviour seems to be consistent now. It only plays if the device isn’t muted. This restriction doesn’t apply to video and audio elements; they will still play even if your device is set to silent.

This descrepancy between the two different ways of playing audio is kind of odd, but at least now the Web Audio behaviour is predictable.

The bad news is that you need to make sure your device isn’t muted before any Web Audio starts playing. Toggling the sound switch during the playback does nothing—you have to reload the page to hear anything. Very annoying!

You can hear the Web Audio API in action by going to any tune on The Session and pressing the “play audio” button.


Print Share Comment Cite Upload Translate
APA
Adactio: Journal | Sciencx (2024-03-29T06:54:31+00:00) » Web Audio API update on iOS. Retrieved from https://www.scien.cx/2023/02/22/web-audio-api-update-on-ios/.
MLA
" » Web Audio API update on iOS." Adactio: Journal | Sciencx - Wednesday February 22, 2023, https://www.scien.cx/2023/02/22/web-audio-api-update-on-ios/
HARVARD
Adactio: Journal | Sciencx Wednesday February 22, 2023 » Web Audio API update on iOS., viewed 2024-03-29T06:54:31+00:00,<https://www.scien.cx/2023/02/22/web-audio-api-update-on-ios/>
VANCOUVER
Adactio: Journal | Sciencx - » Web Audio API update on iOS. [Internet]. [Accessed 2024-03-29T06:54:31+00:00]. Available from: https://www.scien.cx/2023/02/22/web-audio-api-update-on-ios/
CHICAGO
" » Web Audio API update on iOS." Adactio: Journal | Sciencx - Accessed 2024-03-29T06:54:31+00:00. https://www.scien.cx/2023/02/22/web-audio-api-update-on-ios/
IEEE
" » Web Audio API update on iOS." Adactio: Journal | Sciencx [Online]. Available: https://www.scien.cx/2023/02/22/web-audio-api-update-on-ios/. [Accessed: 2024-03-29T06:54:31+00:00]
rf:citation
» Web Audio API update on iOS | Adactio: Journal | Sciencx | https://www.scien.cx/2023/02/22/web-audio-api-update-on-ios/ | 2024-03-29T06:54:31+00:00
https://github.com/addpipe/simple-recorderjs-demo