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: Use correct defaults for configure #110

Merged
merged 1 commit into from
Jun 28, 2024
Merged
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: 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