Pergunta

I've build an web application which plays some songs by using the html5 audio tag. When I'm using FF(firefox) I have to play ogg files, and on IE I have to play mp3 files.

The problem is that i just moved my webapp on godaddy servers, and the FF doesn't play the sounds anymore. On localhost FF play the sounds, but not on godaddy. Chrome plays the sounds on localhost as on godaddy.

This is the code I've use:

<audio id="ff01" src="/files/hello.ogg"></audio>
<audio id="ie01" src="/files/hello.mp3"></audio>
<button class="btn" onClick="document.getElementById('ff01').play()">FF</button>
<button class="btn" onClick="document.getElementById('ie01').play()">IE</button>

Can you tell me why the Firefox plays the files on localhost, but not on godaddy?

Foi útil?

Solução

I solve it by adding the following in the .htaccess file

AddType audio/ogg .ogg
AddType audio/mp3 .mp3

Outras dicas

You should specify the mime type and place each audio file as children of the audio tag; try this:

<audio id="01">
  <source src="/files/hello.ogg" type="audio/ogg">
  <source src="/files/hello.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top