futuraprime
futuraprime

Reputation: 5578

Playing .wav files with WebAudio, served by nginx

I'm working on a project using the WebAudio API to play a number of .wav files. This works fine locally, but when I put the whole thing on my server, it does not work: context.decodeAudioData fails, and returns an empty error.

I noticed that all of the wav files were being served by nginx with a Content-Type of text/html. I've mapped wav to audio/x-wav in the nginx mime.types file, and when I run curl -I against these files, they come back correctly as Content-Type: audio/x-wav. But they persist in showing up in the browser as text/html, and this does not appear to be a browser caching issue.

Is the wrong Content-Type what's preventing these from playing? How can I fix it?

Upvotes: 0

Views: 1202

Answers (2)

futuraprime
futuraprime

Reputation: 5578

The solution turned out to be: there was a problem with the URLs, and my nginx setup was not serving error pages properly.

Upvotes: 1

padenot
padenot

Reputation: 1555

It should not matter: decodeAudioData performs binary sniffing on the data to determine the type.

Do you have some code to show? It might be an issue with the XHR

Upvotes: 0

Related Questions