ObiHill
ObiHill

Reputation: 11876

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;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.

Upvotes: 2

Views: 1858

Answers (3)

ObiHill
ObiHill

Reputation: 11876

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.

Upvotes: 2

Art Gillespie
Art Gillespie

Reputation: 8757

There is no ogg/vorbis decoder on iOS.

Upvotes: 1

AlfredoVR
AlfredoVR

Reputation: 4287

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

Upvotes: 2

Related Questions