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 music stop when the application start #105

Open
PatBoulay opened this issue Oct 22, 2016 · 9 comments
Open

Background music stop when the application start #105

PatBoulay opened this issue Oct 22, 2016 · 9 comments

Comments

@PatBoulay
Copy link

On Android, when I call the function preloadSimple and preloadComplex, the background music(like Google Music) stops.

@polyn0m
Copy link

polyn0m commented Nov 3, 2016

Same problem on iOS, stops music play (Apple Music) when calls preloadSimple and preloadComplex

@antsav
Copy link

antsav commented Dec 6, 2016

+1 same problem
issue also described here https://stackoverflow.com/questions/38690103/cordova-sounds-strop-background-music

@ThibaudD
Copy link
Contributor

ThibaudD commented Dec 6, 2016

I found how to fix it for iOS, it is explained here http://stackoverflow.com/questions/10180500/how-to-use-kaudiosessionproperty-overridecategorymixwithothers
I changed the file 'NativeAudio.m' like that

- (void)pluginInitialize
{
    self.fadeMusic = NO;

    AVAudioSession *session = [AVAudioSession sharedInstance];
    // we activate the audio session after the options to mix with others is set
    [session setActive: NO error: nil];
    NSError *setCategoryError = nil;

    // Allows the application to mix its audio with audio from other apps.
    if (![session setCategory:AVAudioSessionCategoryPlayback
                  withOptions:AVAudioSessionCategoryOptionMixWithOthers
                        error:&setCategoryError]) {

        NSLog (@"Error setting audio session category.");
        return;
    }

    [session setActive: YES error: nil];
}

However, I didn't find how to fix the problem for android.

@AmitMY
Copy link

AmitMY commented Feb 23, 2017

Same problem here. (iOS + Android)
@ThibaudD , do you mind making a pull request?

@jvwelzen
Copy link

If I use the latest version the background music still stops.

If I make a fork and replace the code from @ThibaudD above the background music doesn't stop but the fading does not work

@epetre
Copy link

epetre commented May 25, 2017

It still happens on Android with version 3.0.9

@Rodmg
Copy link

Rodmg commented Nov 14, 2017

I made a pull request #139 for fixing this.

@LuceliaVieira
Copy link

LuceliaVieira commented Nov 28, 2017

I changed plugin version and the issue still happens :(

When I try to listen to music using Spotity, the music stop when I opened the app, but if I try to listen to the song inside the device and open the app, the music doesn't stop.

@50l3r
Copy link

50l3r commented Dec 26, 2019

It still hapens

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

10 participants