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

Fix background music interruption on plugin init on Android and iOS #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/android/NativeAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions src/ios/NativeAudio.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down