Unable to create an AudioContext in Safari

I am almost done with my T3 stack project that heavily relies on the Web Audio API, but have just started testing on safari through Playwright (since I don't have an iphone), and am really at a loss for why I get the error message: "ReferenceError: can't find variable: AudioContext" from the line "const audioContext = new AudioContext()". I have tried all of the popular solutions online (delaying creation until user input + using "window.webkitAudioContext") but this seriously feels like a bug with safari to me. Any help or insights would be greatly appreciated! Repo: https://github.com/michaelongaro/Autostrum ^ file that creates the AudioContext: https://github.com/michaelongaro/Autostrum/blob/a6023dd1deb0935b148902ece517a416920caebd/src/components/Layouts/GeneralLayoutStatefulShell.tsx#L104 Live site: https://www.autostrum.com/
GitHub
GitHub - michaelongaro/Autostrum: Autostrum is a site for guitar pl...
Autostrum is a site for guitar players to create and share their guitar music. Complete with an advanced editor and realistic audio playback. - GitHub - michaelongaro/Autostrum: Autostrum is a site...
Autostrum
Create and share your riffs exactly how you want them to sound. Our advanced tab editor minimizes repetitive actions so you can focus on creating your music. Play along to any tab with our realistic generated audio or directly with the artist's recording.
GitHub
Autostrum/src/components/Layouts/GeneralLayoutStatefulShell.tsx at ...
Autostrum is a site for guitar players to create and share their guitar music. Complete with an advanced editor and realistic audio playback. - michaelongaro/Autostrum
Solution:
I figured out what was going wrong... the creation of the AudioContext was working fine (despite the errors Playwright was showing me), the main issue was that I was trying to decode/use .ogg files and those are currently not supported in Safari.
Jump to solution
1 Reply
Solution
michaelongaro
michaelongaro8mo ago
I figured out what was going wrong... the creation of the AudioContext was working fine (despite the errors Playwright was showing me), the main issue was that I was trying to decode/use .ogg files and those are currently not supported in Safari.