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


#1

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.
see: https://issues.apache.org/jira/browse/CB-12898

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.


#2

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


#3

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


#4

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


#5

Hi, have you made any progress on this?


#6

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


#7

I use PhoneGap and I have the same problem.

I report here https://github.com/EddyVerbruggen/cordova-plugin-backgroundaudio/issues/12

Have you made any progress to share?


#8

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


#9

I’m going to try this https://heshyo.github.io/2016/09/12/Background-audio-and-lockscreen-player-on-iOS-Ionic2-Cordova.html


#10

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


#11

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?!


#12

Are you using ionic WKWebView or UIWebView?

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


#13

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