I'm having an issue with certain MP3 files in Safari only.
Here's a codepen: https://codepen.io/parliament718/pen/ExjwWEp
In chrome, both buttons work to play both files. In safari only the first button works.
Why is this? Does safari just choke when it doesn't see a ".mp3" suffix or is it something else?
- Both requests return "audio/mp3" Content-Type header.
- Both files can be downloaded as mp3s and played in any audio player
- Both files can be played directly through the safari address bar
But only one of the files plays programatically using WebkitAudioContext.
Failing code:
window.webkitAudioContext.decodeAudioData(request.response, ...)
Your MP3 file isn't valid. There is multi-part form garbage at the beginning of the file. If you open it with a hex editor, you'll see it:
Anywhere else that's playing this file is simply being nice to you. :-)
Also, use
audio/mpegfor yourContent-Typeheader. It doesn't matter in your case since you're using the audio context to decode the data... it doesn't know what the originalContent-Typeheader was. I'm mention it here for others, as it's a common mistake.