Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Audio iPAD, Cannot play audio file ?

I got a little issue

I'm trying to play audio files on a webView with html5 on the ipad simulator, i got a code like this:

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

But i always got a "cannot play audio file" on the black bar on control :/

Someone as an idea why ?

Of course my test.mp3 and test.ogg are added in my xcode project and are in the same directory

Thanks

like image 262
John Smith Avatar asked Nov 04 '22 22:11

John Smith


1 Answers

Format attribute in audio doesn't makes any sense. You should use type attribute in source tag.

See example:

<source src="test.ogg" type="audio/ogg" />
<source src="test.mp3" type="audio/mpeg" />

This is working in ipad.

like image 135
iOS Developer Avatar answered Nov 14 '22 20:11

iOS Developer