0

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, ...)
Brad
  • 159,648
  • 54
  • 349
  • 530
parliament
  • 21,544
  • 38
  • 148
  • 238

1 Answers1

1

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:

Hex Editor View

Anywhere else that's playing this file is simply being nice to you. :-)

Also, use audio/mpeg for your Content-Type header. It doesn't matter in your case since you're using the audio context to decode the data... it doesn't know what the original Content-Type header was. I'm mention it here for others, as it's a common mistake.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • You sir are a savior, thanks. I was using AWS presigned url and sending ```FormData``` instead of the ```File``` object directly. Literally everything else plays it... Safari is so mean! – parliament Mar 06 '20 at 17:53