开发者

How to create an iOS safe audio player

I am trying to create a simple audio player that will work in iOS for use with iPhone and iPad.

The audio is obtained from base64 encoded data (which I created using PHP base64 encoding function).

Here is my code below:

<audio controls="controls" autobuffer="autobuffer" autoplay="autoplay">
    <source src="data:audio/ogg开发者_JS百科;base64,{my_base64_data}" />
</audio>

However, this works in Firefox, but it doesn't work in Safari.

Is there something I'm doing wrong?

Kindly assist.

Thanks.


I think safari doesn't do ogg at all. I might be wrong or tried a bad file, but i couldn't play ogg.


Ok, I managed to solve this.

I simply created an mp4 alternative to the ogg, encoded to base64, and added another source tag with the raw base64 data.

<audio controls="controls" autobuffer="autobuffer" autoplay="autoplay">
    <source src="data:audio/mp4;base64,{my_base64_data_for_mp4}" />
    <source src="data:audio/ogg;base64,{my_base64_data_for_ogg}" />
</audio>

Seems to be working without any issues so far.


There is no ogg/vorbis decoder on iOS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜