HTML5 Audio iPAD, Can't play the audio file?

I have a little problem

I am trying to play audio files in webView with html5 on ipad simulator, I have code like this:

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

But I always got "can't play audio file" on the black control panel: /

Someone like an idea why?

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

thank

+5
source share
1 answer

The format attribute in audio makes no sense. You must use the type attribute in the source tag.

See an example:

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

This works on ipad.

+2
source

All Articles