From 2ca635f8fced9de88758e73cba751c8d772026be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20M=C3=A9ndez=20Gamboa?= Date: Tue, 14 Nov 2017 14:17:20 -0600 Subject: [PATCH 1/2] Fix background music interruption on app startup on ios --- src/ios/NativeAudio.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/ios/NativeAudio.m b/src/ios/NativeAudio.m index e797d1c9..35747429 100644 --- a/src/ios/NativeAudio.m +++ b/src/ios/NativeAudio.m @@ -29,10 +29,8 @@ - (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. @@ -43,9 +41,6 @@ - (void)pluginInitialize NSLog (@"Error setting audio session category."); return; } - - [session setActive: YES error: nil]; - [session setCategory:AVAudioSessionCategoryPlayback error:nil]; } - (void) parseOptions:(NSDictionary*) options From 90cbcdef5a50cf141527d97d6916e7bb95d14c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20M=C3=A9ndez=20Gamboa?= Date: Tue, 14 Nov 2017 15:57:04 -0600 Subject: [PATCH 2/2] Avoid stopping background music on Android --- src/android/NativeAudio.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/android/NativeAudio.java b/src/android/NativeAudio.java index e22f07a9..64160097 100644 --- a/src/android/NativeAudio.java +++ b/src/android/NativeAudio.java @@ -201,14 +201,6 @@ private PluginResult executeSetVolumeForComplexAsset(JSONArray data) { } @Override protected void pluginInitialize() { - AudioManager am = (AudioManager)cordova.getActivity().getSystemService(Context.AUDIO_SERVICE); - - int result = am.requestAudioFocus(this, - // Use the music stream. - AudioManager.STREAM_MUSIC, - // Request permanent focus. - AudioManager.AUDIOFOCUS_GAIN); - // Allow android to receive the volume events this.webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_DOWN, false); this.webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_UP, false);