Native Audio pausing music app; can't fix

I’m building a timer app which has a mp3 firing off with the Native Audio plugin (https://ionicframework.com/docs/native/native-audio/), but the music pauses for the sound effect and doesn’t resume or lower. Just flat out pauses. Does anyone know a work around to this to keep the music playing, say through Spotify, and also play an audio sound effect?

Thanks,
Steve

Actually found a fix for the issue, it’s in this thread: https://github.com/floatinghotpot/cordova-plugin-nativeaudio/issues/75

Essentially find the NativeAudio.m file and swap out these lines

Original
// - (void)pluginInitialize
// {
// self.fadeMusic = NO;
//
// AudioSessionInitialize(NULL, NULL, nil , nil);
// 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:AVAudioSessionCategoryAmbient
// withOptions:AVAudioSessionCategoryOptionMixWithOthers
// error:&setCategoryError]) {
//
// NSLog (@“Error setting audio session category.”);
// return;
// }
//
// [session setActive: YES error: nil];
// [session setCategory:AVAudioSessionCategoryPlayback error:nil];
// }

Modified

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

    AudioSessionInitialize(NULL, NULL, nil , nil);
    AVAudioSession *session = [AVAudioSession sharedInstance];

    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;
    

    }
    }

Maybe this will help someone in the future