nypublicradio / ember-hifi

The easy way to play audio in your ember app
MIT License
45 stars 10 forks source link

Event for mobile audio loading failure #44

Open jurecuhalev opened 7 years ago

jurecuhalev commented 7 years ago

On mobile, it's possible for audio to fail due to: Looks like the mobile browser blocked an autoplay trying to play sound with url ..

Would it make sense to trigger an event, e.g. audio-blocked ? (I would also assume that audio-load-error would load in this case, but it doesn't)

This would allow then to change UI to indicate to user that they should click on element manually.

jkeen commented 7 years ago

Thanks for reporting!

It really should fire something, and I like the idea of audio-blocked. It's not exactly a failure worthy of an audio-load-error in my opinion since the file loaded and is just sitting paused waiting for user interaction. Currently there's a hack in there that ties into the document touchstart event to play the audio after it's been blocked, but adding an additional event for a consumer to tie into sounds like a solid idea to me.

jkeen commented 4 years ago

@gandalfar Started work on this and feel free to pick it up if you're feeling motivated. I stalled out on some HLS problems and have to switch gears for a bit. Not sure when I'll get back on it

jkeen commented 3 years ago

@gandalfar This is still an issue in ember-hifi, but I will report that the fork of hifi I made called ember-stereo has an audio-blocked event and helpers to deal with browser blocking autoplay. Check out the changes at http://ember-stereo.com

jurecuhalev commented 3 years ago

@jkeen thank you!