Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background-Mode pauses my background music in iOS #437

Open
wynngd opened this issue Mar 18, 2019 · 8 comments
Open

Background-Mode pauses my background music in iOS #437

wynngd opened this issue Mar 18, 2019 · 8 comments

Comments

@wynngd
Copy link

wynngd commented Mar 18, 2019

While playing music using in the background via my media apps (Apple Music, or Spotify), the music pauses whenever I launches my ionic app 3.9 with background-mode. I am using the head version and Ionic 3.9.2, I've disabled the Audio, Airplay, and Picture in Picture in Capabilities in XCode as well. Is there a way to go around this issue? Thank you!

@ghenry22
Copy link

this is because this plugin plays a small audio file in the background to simulate legitimate activity in the background, this audio will steal the audio session. You can easily modify the plugin to just not play the audio if you have valid background use cases which will keep things active, which is a better approach for anything being distributed anyway.

@wynngd
Copy link
Author

wynngd commented Apr 29, 2019

this is because this plugin plays a small audio file in the background to simulate legitimate activity in the background, this audio will steal the audio session. You can easily modify the plugin to just not play the audio if you have valid background use cases which will keep things active, which is a better approach for anything being distributed anyway.

Thanks! does this mean, if I need a background process (does not need any audio), the small audio file still needs to play?

@rijink7
Copy link

rijink7 commented Jul 26, 2019

@wynngd i'm facing the same error, did you any solution ?

@wynngd
Copy link
Author

wynngd commented Jul 26, 2019

@wynngd i'm facing the same error, did you any solution ?

I didn’t get a fix for this one. We’ll try to fix it on our next version. I’ll update the this thread when I come up with one.

@leyk0001
Copy link

I think this may be related to a code change to APPBackgroundMode.m (commit e939b13 on Jan 9, 2018) where "withOptions:AVAudioSessionCategoryOptionMixWithOthers" was removed, i.e.:

[session setCategory:AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers
error:NULL];

was changed to:

[session setCategory:AVAudioSessionCategoryPlayback
error:NULL];

@rodrigoti
Copy link

rodrigoti commented Nov 6, 2019

I think this may be related to a code change to APPBackgroundMode.m (commit e939b13 on Jan 9, 2018) where "withOptions:AVAudioSessionCategoryOptionMixWithOthers" was removed, i.e.:

[session setCategory:AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers
error:NULL];

was changed to:

[session setCategory:AVAudioSessionCategoryPlayback
error:NULL];

Is now working pretty fine. Thank you!

@mutableideas
Copy link

I can confirm that modifying the APPBackgroundMode.m file as noted above fixed the issue of stopping my music on iOS.

I think this may be related to a code change to APPBackgroundMode.m (commit e939b13 on Jan 9, 2018) where "withOptions:AVAudioSessionCategoryOptionMixWithOthers" was removed, i.e.:
[session setCategory:AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers
error:NULL];
was changed to:
[session setCategory:AVAudioSessionCategoryPlayback
error:NULL];

Is now working pretty fine. Thank you!

This fix also worked for me.

@EinfachHans
Copy link

i think this Plugin is not maintained anymore, so i decided to create a new one and fix this Issue. It also has a Ionic Wrapper, so go ahead and use this: https://github.com/HansKrywaa/cordova-plugin-advanced-background-mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants