cordova-plugin-nativeaudio icon indicating copy to clipboard operation
cordova-plugin-nativeaudio copied to clipboard

Background music stop when the application start

Open PatBoulay opened this issue 9 years ago • 9 comments
trafficstars

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

PatBoulay avatar Oct 22 '16 02:10 PatBoulay

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

polyn0m avatar Nov 03 '16 10:11 polyn0m

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

antsav avatar Dec 06 '16 09:12 antsav

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.

ThibaudD avatar Dec 06 '16 14:12 ThibaudD

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

AmitMY avatar Feb 23 '17 09:02 AmitMY

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

jvwelzen avatar Mar 22 '17 10:03 jvwelzen

It still happens on Android with version 3.0.9

epetre avatar May 25 '17 15:05 epetre

I made a pull request #139 for fixing this.

Rodmg avatar Nov 14 '17 22:11 Rodmg

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.

LuceliaVieira avatar Nov 28 '17 19:11 LuceliaVieira

It still hapens

50l3r avatar Dec 26 '19 22:12 50l3r