Cordova-plugin-media - iOS - Audio not starting when app in background

Hi guys,

I’m not sure where to post about this, so I’m going to do it here. I already created a bug in the cordova apache but had no response.

The issue is with a new media file that can’t be “STARTED” when the screen is locked (or app is in background).
I’m not referring to the background playing settings in iOS.

This still happens even if I set the UIBackgroundModes setting.

Steps to produce:
1- Play File A from the App (Plays fine)
2- Lock the screen (Audio continues to play)
3- audio finishes and tries to start the next audio (in case of playing a playlist) (This fails)

The audio does not start in step 3.

this only happens in iOS. Android is fine.

Anyone with a suggestion?? am I missing something? please help.

I have the same issue. Have you found a fix?

Hi, no I couldn’t.
I believe the only way to get this to work is to use AvQueuePlayer and load the whole playlist.

Hi, have you made any progress on this?

I’m more convinced that this is a JavaScript issue more than a Cordova Media Plugin issue. However, I’m still not sure on how to resolve it.

It seems that when the first song finishes playing and the JavaScript tries to start the next song in the songs array, the JavaScript does not run when the phone is locked (app is in background).

I use PhoneGap and I have the same problem.

I report here

Have you made any progress to share?

Not really.
I’m actually testing to see if NativeScript will be a better solution for my case.

I’m going to try this

Thats a different issue. Please let me know how you go.

I’m facing the same issue.

  • It’s working fine in android.

  • It’s working fine in the iPhone simulator.

  • It’s not working on the iPhone device!

Any solutions?!

Are you using ionic WKWebView or UIWebView?

WKWebView will not run any JS while the app is in background.
UIWebView should work fine.

I’m using UIWebView.
as I mentioned it’s working fine in the simulator but not in the device!

Hello. Did you found a solution to this issue?

Use the UIWebView and not the new view