Howler.js: iOS Lock Screen - Should Audio still play?

Created on 26 May 2018  路  7Comments  路  Source: goldfire/howler.js

On my android device audio plays when the screen is locked.

Now I got a report that the audio stops playing when the screen is locked on iOS. Unfortunately I can't test it because I don't have an iOS device.
Anyone knows if this is this by apple policy? Any work around?

new Howl({
            src: [track],
            html5: true,
            loop: false,
            preload: true,
            autoplay: false,
            onload: function() {
...

Most helpful comment

This is due to the Auto-play policy on iOS Safari. In Playlist another audio won't start automatically because it requires a user interaction.

I overcame this issue by playing a silent audio on loop with html5: true flag. This will keep the context alive for audios. Then you can play rest of the files in sequence with html5: false flag.

All 7 comments

I tried the demo Music Player on this page https://howlerjs.com/ on an iPad Pro and it would not advance the playlist after the first track on the lock screen :(

This is due to the Auto-play policy on iOS Safari. In Playlist another audio won't start automatically because it requires a user interaction.

I overcame this issue by playing a silent audio on loop with html5: true flag. This will keep the context alive for audios. Then you can play rest of the files in sequence with html5: false flag.

@aareeph could you possibly elaborate on your playing silent audio loop? Does this work on iOS and android?

I've tried what you suggested but it's had no effect. Example code would be really appreciated!

Hi @rlyttle, actually the silent audio loop trick didn't work for me very well for iOS. Although I was able to play next audio without user interaction, this wasn't working fine when the app is in background or device is locked.

For Android everything worked fine and we don't need to do the silent audio loop trick at all.

Please have a look at these release notes. Author has updated the library to play next audios in a pool without any user interaction. So I believe that you don't need any workaround for now.
https://github.com/goldfire/howler.js/blob/master/CHANGELOG.md#210-december-12-2018

@aareeph Thanks for the detailed response! I'll do some investigation!

Closing due to inactivity. If this is still an issue, reply with more info and I'll reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FFankias picture FFankias  路  3Comments

st-h picture st-h  路  5Comments

jacobedawson picture jacobedawson  路  3Comments

inglesuniversal picture inglesuniversal  路  4Comments

lili21 picture lili21  路  4Comments