Skip to content

Commit

Permalink
fix: Use correct defaults for configure (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jun 28, 2024
1 parent 1e8c3e7 commit b5363a2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ Listen for asset completed playing event

#### ConfigureOptions

| Prop | Type | Description | Default |
| ----------- | -------------------- | ------------------------------------------------- | ----------------- |
| **`fade`** | <code>boolean</code> | indicating whether or not to fade audio. | <code>true</code> |
| **`focus`** | <code>boolean</code> | indicating whether or not to disable mixed audio. | <code>true</code> |
| Prop | Type | Description | Default |
| ----------- | -------------------- | ------------------------------------------------- | ------------------ |
| **`fade`** | <code>boolean</code> | Indicating whether or not to fade audio. | <code>false</code> |
| **`focus`** | <code>boolean</code> | Indicating whether or not to disable mixed audio. | <code>false</code> |


#### PreloadOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 8 additions & 12 deletions ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
9 changes: 5 additions & 4 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b5363a2

Please sign in to comment.