Saad Lamarti
Saad Lamarti

Reputation: 300

Playing audio with HTML5 in Android browser

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)

Upvotes: 8

Views: 14657

Answers (2)

Asyraf Azmin
Asyraf Azmin

Reputation: 41

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 :)

Upvotes: 2

cstrutton
cstrutton

Reputation: 6187

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

Upvotes: 1

Related Questions