From b5363a208fe28b306720918842a114e775a0d471 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Fri, 28 Jun 2024 17:40:31 +0200 Subject: [PATCH] fix: Use correct defaults for configure (#110) --- README.md | 8 ++++---- .../community/audio/NativeAudio.java | 4 ++-- ios/Plugin/Plugin.swift | 20 ++++++++----------- src/definitions.ts | 9 +++++---- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 2829b86..8071eb8 100644 --- a/README.md +++ b/README.md @@ -395,10 +395,10 @@ Listen for asset completed playing event #### ConfigureOptions -| Prop | Type | Description | Default | -| ----------- | -------------------- | ------------------------------------------------- | ----------------- | -| **`fade`** | boolean | indicating whether or not to fade audio. | true | -| **`focus`** | boolean | indicating whether or not to disable mixed audio. | true | +| Prop | Type | Description | Default | +| ----------- | -------------------- | ------------------------------------------------- | ------------------ | +| **`fade`** | boolean | Indicating whether or not to fade audio. | false | +| **`focus`** | boolean | Indicating whether or not to disable mixed audio. | false | #### PreloadOptions diff --git a/android/src/main/java/com/getcapacitor/community/audio/NativeAudio.java b/android/src/main/java/com/getcapacitor/community/audio/NativeAudio.java index e4eaf6c..345fe6d 100644 --- a/android/src/main/java/com/getcapacitor/community/audio/NativeAudio.java +++ b/android/src/main/java/com/getcapacitor/community/audio/NativeAudio.java @@ -108,10 +108,10 @@ protected void handleOnResume() { public void configure(PluginCall call) { initSoundPool(); - this.fadeMusic = call.getBoolean(OPT_FADE_MUSIC, true); + this.fadeMusic = call.getBoolean(OPT_FADE_MUSIC, false); if (this.audioManager != null) { - if (call.getBoolean(OPT_FOCUS_AUDIO, true)) { + if (call.getBoolean(OPT_FOCUS_AUDIO, false)) { this.audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); } else { this.audioManager.abandonAudioFocus(this); diff --git a/ios/Plugin/Plugin.swift b/ios/Plugin/Plugin.swift index f393a47..19cf1d3 100644 --- a/ios/Plugin/Plugin.swift +++ b/ios/Plugin/Plugin.swift @@ -32,19 +32,15 @@ public class NativeAudio: CAPPlugin { } @objc func configure(_ call: CAPPluginCall) { - if let fade = call.getBool(Constant.FadeKey) { - self.fadeMusic = fade - } - if let focus = call.getBool(Constant.FocusAudio) { - do { - if focus { - try self.session.setCategory(AVAudioSession.Category.playback) - } else { - try self.session.setCategory(AVAudioSession.Category.ambient) - } - } catch { - print("Failed to set setCategory audio") + self.fadeMusic = call.getBool(Constant.FadeKey, false) + do { + if call.getBool(Constant.FocusAudio, false) { + try self.session.setCategory(AVAudioSession.Category.playback) + } else { + try self.session.setCategory(AVAudioSession.Category.ambient) } + } catch { + print("Failed to set setCategory audio") } call.resolve() } diff --git a/src/definitions.ts b/src/definitions.ts index 088c684..f06dc55 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -23,13 +23,14 @@ export interface NativeAudio { export interface ConfigureOptions { /** - * indicating whether or not to fade audio. - * @default true + * Indicating whether or not to fade audio. + * @default false */ fade?: boolean; /** - * indicating whether or not to disable mixed audio. - * @default true */ + * Indicating whether or not to disable mixed audio. + * @default false + */ focus?: boolean; }