8

I want to play audio in the Android browser, using the html5 <audio> tag. It works fine in the iPhone browser, but not in Android. I'm using Android Virtual Device 4.0.3.

Does anyone know why?

The Android source:

webView.loadUrl("file:///android_asset/www/test.html");

The HTML file:

<audio controls="controls" format="mp3">
    <source src="achievement.mp3" /> 
</audio>

(i couldn't hear the audio with <embed> and <object> tags either)

Mick F
  • 7,312
  • 6
  • 51
  • 98
Saad Lamarti
  • 300
  • 1
  • 5
  • 15

2 Answers2

2

I found the solution here Embed Background Audio in Android >= 2.3 Browser

<audio id="audio1" controls="controls" loop="loop" autoplay="autoplay" >
   <source src="scene1.mp3" type="audio/mpeg" />
   <source src="scene1.ogg" type="audio/ogg" />
</audio>

it's work for me :)

Community
  • 1
  • 1
1

I did a quick search and found this issue report on google code. It seems the tag is unsupported. However, the tag is and can play mp3 files. The down side is (if I read it correctly) that the controls are not available. Give it a read and let us know how you make out.

I found another question that has lots of different possible solutions: Check it out

Community
  • 1
  • 1
cstrutton
  • 5,667
  • 3
  • 25
  • 32
  • I think the problem is only for Android 2.x. It should work for Honeycomb and Ice Cream Sandwich. – Mick F Jun 06 '12 at 08:37
  • I found lots of different issues with several versions of android. The general concencus was that it was supposed to be fixed but is still broken. You may be right though I haven't had the time to try it out. – cstrutton Jun 06 '12 at 09:08
  • Actually, I didn't try myself, I am just relying on this: http://html5test.com/compare/browser/android40/ios50.html – Mick F Jun 06 '12 at 09:50