Amir Gonnen
Amir Gonnen

Reputation: 3727

HTML5 audio blob would not play on Android

I'm serving an audio file (WAV file that contains a short uncompressed PCM) from my GAE app using BlobStore. On a click event, I set audio.src and call audio.play().

Now here is the weird part:

No error is shown - it just plays nothing. As far as I can tell from GAE logs, the audio file is served in all cases. In case of Android I can see a requests from "Player/LG Player 1.0 for Android 4.4.2 (stagefright alternative)".

Any idea what's going on, or how to debug this?


Update

Tried playing files from Google Cloud Storage, according to Stuart Langley's suggestion.
In that case, Android plays well, and IOS doesn't (intermittently. Sometimes gives an error).

So a workaround that works for me is storing the file on Cloud Storage, and also calling createGsBlobKey in order to serve it as a blob. On the client side I check whether it's Android (navigator.userAgent.match(/Android/i)). In case of Android I set audio.src to the Cloud Storage file, and in case of IOS I set it to my servlet which serves the file using BlobstoreService.serve with the blob key I got from createGsBlobKey.

This is a cumbersome workaround and I didn't check other mobile OSs to see what works for each, so if anyone has a better solution please let me know.

Upvotes: 1

Views: 1109

Answers (1)

Stuart Langley
Stuart Langley

Reputation: 7054

Most likely this is due to the chunked response when serving a blob.

Here is an issue tracker item about audio files not playing correctly in some browsers.

Here is a test web site I put together while back that illustrates the problem.

As for workarounds - You can put the file on cloud storage and then play it from there, as long as you're not concerned about people hotlinking the file.

Upvotes: 1

Related Questions