HTML5 Audio not working for Android

I am creating a page with an embedded audio player that works on all systems I have tested, except on Android. The players do appear on the page, but you cannot start them playing.

I’ve tried both the <audio> tag and SoundManager 2, checked whether the device does normally play mp3 files with HTML5 Audio Formats Test (which it does), and downloaded that same test to my server and checked whether it worked there (which it doesn’t). And I cannot find anything helpful in the log files.

Any ideas what I could do?

edit: I have since tried the same with Apache on the same server and with Nginx on another server with the same results.

Answer

I tried the files on my nginx server and all of them except flac work on android 4.4 with the default Browser and Firefox.

This is the tag I used:

<audio preload="auto" controls="">
   <source src="Test/Audio/mp3.mp3" type="audio/mpeg">
</audio>

Maybe you have not set your mime types in the nginx configuration correctly.
You will need:

types {
  audio/mpeg                          mp3;
  audio/ogg                           oga ogg opus;
  audio/webm                          weba;
  audio/vnd.wave                      wav;
}

This can be done by importing mime.types in the server block and adding missing types.

If this did not help please write which browser/version you use 😉

Attribution
Source : Link , Question Author : Pascal , Answer Author : zuim

Leave a Comment