react-native-audio-api 0.12.0-nightly-75589dc-20260121 → 0.12.0-nightly-6993a06-20260122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +16 -2
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +7 -3
- package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +6 -6
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.cpp +18 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.h +4 -0
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +29 -14
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +7 -0
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +1 -1
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +1 -1
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +8 -2
- package/ios/audioapi/ios/AudioAPIModule.h +2 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +3 -3
- package/ios/audioapi/ios/system/AudioEngine.mm +3 -1
- package/ios/audioapi/ios/system/AudioSessionManager.h +1 -0
- package/ios/audioapi/ios/system/{NotificationManager.h → SystemNotificationManager.h} +1 -1
- package/ios/audioapi/ios/system/{NotificationManager.mm → SystemNotificationManager.mm} +9 -4
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js +15 -0
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioBufferSourceNode.js +0 -6
- package/lib/commonjs/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +2 -2
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/OscillatorNode.js +0 -6
- package/lib/commonjs/core/OscillatorNode.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.web.js.map +1 -1
- package/lib/commonjs/system/AudioManager.js +7 -2
- package/lib/commonjs/system/AudioManager.js.map +1 -1
- package/lib/commonjs/web-core/AudioScheduledSourceNode.js +4 -2
- package/lib/commonjs/web-core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/module/core/AudioBufferQueueSourceNode.js +15 -0
- package/lib/module/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/module/core/AudioBufferSourceNode.js +0 -6
- package/lib/module/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/module/core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +2 -2
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/OscillatorNode.js +0 -6
- package/lib/module/core/OscillatorNode.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.web.js.map +1 -1
- package/lib/module/system/AudioManager.js +7 -2
- package/lib/module/system/AudioManager.js.map +1 -1
- package/lib/module/web-core/AudioScheduledSourceNode.js +4 -2
- package/lib/module/web-core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts +5 -0
- package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioBufferSourceNode.d.ts +0 -2
- package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioScheduledSourceNode.d.ts +3 -3
- package/lib/typescript/core/AudioScheduledSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +4 -4
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/OscillatorNode.d.ts +0 -3
- package/lib/typescript/core/OscillatorNode.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +6 -4
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +1 -0
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts +2 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts +2 -2
- package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts.map +1 -1
- package/lib/typescript/system/AudioManager.d.ts +2 -2
- package/lib/typescript/system/AudioManager.d.ts.map +1 -1
- package/lib/typescript/system/types.d.ts +2 -1
- package/lib/typescript/system/types.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioScheduledSourceNode.d.ts +2 -0
- package/lib/typescript/web-core/AudioScheduledSourceNode.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/AudioBufferQueueSourceNode.ts +31 -0
- package/src/core/AudioBufferSourceNode.ts +0 -10
- package/src/core/AudioScheduledSourceNode.ts +4 -4
- package/src/core/BaseAudioContext.ts +6 -6
- package/src/core/OscillatorNode.ts +0 -11
- package/src/events/types.ts +6 -4
- package/src/interfaces.ts +3 -0
- package/src/specs/NativeAudioAPIModule.ts +6 -1
- package/src/specs/NativeAudioAPIModule.web.ts +6 -2
- package/src/system/AudioManager.ts +8 -2
- package/src/system/types.ts +7 -1
- package/src/web-core/AudioScheduledSourceNode.tsx +6 -1
|
@@ -2,8 +2,10 @@ import AudioNode from './AudioNode';
|
|
|
2
2
|
import { EventEmptyType } from '../events/types';
|
|
3
3
|
export default class AudioScheduledSourceNode extends AudioNode {
|
|
4
4
|
protected hasBeenStarted: boolean;
|
|
5
|
+
private onEndedCallback?;
|
|
5
6
|
start(when?: number): void;
|
|
6
7
|
stop(when?: number): void;
|
|
8
|
+
get onEnded(): ((event: EventEmptyType) => void) | undefined;
|
|
7
9
|
set onEnded(callback: (event: EventEmptyType) => void | null);
|
|
8
10
|
}
|
|
9
11
|
//# sourceMappingURL=AudioScheduledSourceNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioScheduledSourceNode.d.ts","sourceRoot":"","sources":["../../../src/web-core/AudioScheduledSourceNode.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAC7D,SAAS,CAAC,cAAc,EAAE,OAAO,CAAS;
|
|
1
|
+
{"version":3,"file":"AudioScheduledSourceNode.d.ts","sourceRoot":"","sources":["../../../src/web-core/AudioScheduledSourceNode.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAC7D,SAAS,CAAC,cAAc,EAAE,OAAO,CAAS;IAC1C,OAAO,CAAC,eAAe,CAAC,CAAkC;IAEnD,KAAK,CAAC,IAAI,GAAE,MAAU,GAAG,IAAI;IAe7B,IAAI,CAAC,IAAI,GAAE,MAAU,GAAG,IAAI;IAgBnC,IAAW,OAAO,IAAI,CAAC,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC,GAAG,SAAS,CAElE;IAED,IAAW,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI,EAGlE;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.12.0-nightly-
|
|
3
|
+
"version": "0.12.0-nightly-6993a06-20260122",
|
|
4
4
|
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification",
|
|
5
5
|
"bin": {
|
|
6
6
|
"setup-rn-audio-api-web": "./scripts/setup-rn-audio-api-web.js"
|
|
@@ -5,8 +5,13 @@ import { RangeError } from '../errors';
|
|
|
5
5
|
import BaseAudioContext from './BaseAudioContext';
|
|
6
6
|
import { TBaseAudioBufferSourceOptions } from '../types';
|
|
7
7
|
import { BaseAudioBufferSourceOptions } from '../defaults';
|
|
8
|
+
import { AudioEventSubscription } from '../events';
|
|
9
|
+
import { OnBufferEndEventType } from '../events/types';
|
|
8
10
|
|
|
9
11
|
export default class AudioBufferQueueSourceNode extends AudioBufferBaseSourceNode {
|
|
12
|
+
private onBufferEndedSubscription?: AudioEventSubscription;
|
|
13
|
+
private onBufferEndedCallback?: (event: OnBufferEndEventType) => void;
|
|
14
|
+
|
|
10
15
|
constructor(
|
|
11
16
|
context: BaseAudioContext,
|
|
12
17
|
options?: TBaseAudioBufferSourceOptions
|
|
@@ -65,6 +70,32 @@ export default class AudioBufferQueueSourceNode extends AudioBufferBaseSourceNod
|
|
|
65
70
|
(this.node as IAudioBufferQueueSourceNode).stop(when);
|
|
66
71
|
}
|
|
67
72
|
|
|
73
|
+
public get onBufferEnded():
|
|
74
|
+
| ((event: OnBufferEndEventType) => void)
|
|
75
|
+
| undefined {
|
|
76
|
+
return this.onBufferEndedCallback;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public set onBufferEnded(
|
|
80
|
+
callback: ((event: OnBufferEndEventType) => void) | null
|
|
81
|
+
) {
|
|
82
|
+
if (!callback) {
|
|
83
|
+
(this.node as IAudioBufferQueueSourceNode).onBufferEnded = '0';
|
|
84
|
+
this.onBufferEndedSubscription?.remove();
|
|
85
|
+
this.onBufferEndedSubscription = undefined;
|
|
86
|
+
this.onBufferEndedCallback = undefined;
|
|
87
|
+
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.onBufferEndedCallback = callback;
|
|
92
|
+
this.onBufferEndedSubscription =
|
|
93
|
+
this.audioEventEmitter.addAudioEventListener('bufferEnded', callback);
|
|
94
|
+
|
|
95
|
+
(this.node as IAudioBufferQueueSourceNode).onBufferEnded =
|
|
96
|
+
this.onBufferEndedSubscription.subscriptionId;
|
|
97
|
+
}
|
|
98
|
+
|
|
68
99
|
public pause(): void {
|
|
69
100
|
(this.node as IAudioBufferQueueSourceNode).pause();
|
|
70
101
|
}
|
|
@@ -97,16 +97,6 @@ export default class AudioBufferSourceNode extends AudioBufferBaseSourceNode {
|
|
|
97
97
|
(this.node as IAudioBufferSourceNode).start(when, offset, duration);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
public override get onEnded(): ((event: EventEmptyType) => void) | undefined {
|
|
101
|
-
return super.onEnded as ((event: EventEmptyType) => void) | undefined;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public override set onEnded(
|
|
105
|
-
callback: ((event: EventEmptyType) => void) | null
|
|
106
|
-
) {
|
|
107
|
-
super.onEnded = callback;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
100
|
public get onLoopEnded(): ((event: EventEmptyType) => void) | undefined {
|
|
111
101
|
return this.onLoopEndedCallback;
|
|
112
102
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IAudioScheduledSourceNode } from '../interfaces';
|
|
2
2
|
import AudioNode from './AudioNode';
|
|
3
3
|
import { InvalidStateError, RangeError } from '../errors';
|
|
4
|
-
import {
|
|
4
|
+
import { EventEmptyType } from '../events/types';
|
|
5
5
|
import { AudioEventEmitter, AudioEventSubscription } from '../events';
|
|
6
6
|
|
|
7
7
|
export default class AudioScheduledSourceNode extends AudioNode {
|
|
@@ -11,7 +11,7 @@ export default class AudioScheduledSourceNode extends AudioNode {
|
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
private onEndedSubscription?: AudioEventSubscription;
|
|
14
|
-
private onEndedCallback?: (event:
|
|
14
|
+
private onEndedCallback?: (event: EventEmptyType) => void;
|
|
15
15
|
|
|
16
16
|
public start(when: number = 0): void {
|
|
17
17
|
if (when < 0) {
|
|
@@ -44,11 +44,11 @@ export default class AudioScheduledSourceNode extends AudioNode {
|
|
|
44
44
|
(this.node as IAudioScheduledSourceNode).stop(when);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
public get onEnded(): ((event:
|
|
47
|
+
public get onEnded(): ((event: EventEmptyType) => void) | undefined {
|
|
48
48
|
return this.onEndedCallback;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
public set onEnded(callback: ((event:
|
|
51
|
+
public set onEnded(callback: ((event: EventEmptyType) => void) | null) {
|
|
52
52
|
if (!callback) {
|
|
53
53
|
(this.node as IAudioScheduledSourceNode).onEnded = '0';
|
|
54
54
|
this.onEndedSubscription?.remove();
|
|
@@ -158,10 +158,10 @@ export default class BaseAudioContext {
|
|
|
158
158
|
return new BiquadFilterNode(this);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
createBufferSource(options
|
|
162
|
-
pitchCorrection
|
|
161
|
+
createBufferSource(options?: {
|
|
162
|
+
pitchCorrection: boolean;
|
|
163
163
|
}): AudioBufferSourceNode {
|
|
164
|
-
if (options
|
|
164
|
+
if (options !== undefined) {
|
|
165
165
|
return new AudioBufferSourceNode(this, options);
|
|
166
166
|
} else {
|
|
167
167
|
return new AudioBufferSourceNode(this);
|
|
@@ -195,10 +195,10 @@ export default class BaseAudioContext {
|
|
|
195
195
|
return new IIRFilterNode(this, { feedforward, feedback });
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
createBufferQueueSource(options
|
|
199
|
-
pitchCorrection
|
|
198
|
+
createBufferQueueSource(options?: {
|
|
199
|
+
pitchCorrection: boolean;
|
|
200
200
|
}): AudioBufferQueueSourceNode {
|
|
201
|
-
if (options
|
|
201
|
+
if (options !== undefined) {
|
|
202
202
|
return new AudioBufferQueueSourceNode(this, options);
|
|
203
203
|
} else {
|
|
204
204
|
return new AudioBufferQueueSourceNode(this);
|
|
@@ -4,7 +4,6 @@ import AudioParam from './AudioParam';
|
|
|
4
4
|
import BaseAudioContext from './BaseAudioContext';
|
|
5
5
|
import PeriodicWave from './PeriodicWave';
|
|
6
6
|
import { InvalidStateError } from '../errors';
|
|
7
|
-
import { EventEmptyType } from '../events/types';
|
|
8
7
|
import { OscillatorOptions } from '../defaults';
|
|
9
8
|
import { TOscillatorOptions } from '../types';
|
|
10
9
|
|
|
@@ -46,14 +45,4 @@ export default class OscillatorNode extends AudioScheduledSourceNode {
|
|
|
46
45
|
public setPeriodicWave(wave: PeriodicWave): void {
|
|
47
46
|
(this.node as IOscillatorNode).setPeriodicWave(wave.periodicWave);
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
public override get onEnded(): ((event: EventEmptyType) => void) | undefined {
|
|
51
|
-
return super.onEnded as ((event: EventEmptyType) => void) | undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public override set onEnded(
|
|
55
|
-
callback: ((event: EventEmptyType) => void) | null
|
|
56
|
-
) {
|
|
57
|
-
super.onEnded = callback;
|
|
58
|
-
}
|
|
59
48
|
}
|
package/src/events/types.ts
CHANGED
|
@@ -46,12 +46,13 @@ interface RemoteCommandEvents {
|
|
|
46
46
|
type SystemEvents = RemoteCommandEvents & {
|
|
47
47
|
volumeChange: EventTypeWithValue;
|
|
48
48
|
interruption: OnInterruptionEventType;
|
|
49
|
+
duck: EventEmptyType;
|
|
49
50
|
routeChange: OnRouteChangeEventType;
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
export interface
|
|
53
|
-
bufferId: string
|
|
54
|
-
|
|
53
|
+
export interface OnBufferEndEventType {
|
|
54
|
+
bufferId: string;
|
|
55
|
+
isLastBufferInQueue: boolean;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -79,10 +80,11 @@ export interface OnAudioReadyEventType {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
interface AudioAPIEvents {
|
|
82
|
-
ended:
|
|
83
|
+
ended: EventEmptyType;
|
|
83
84
|
loopEnded: EventEmptyType;
|
|
84
85
|
audioReady: OnAudioReadyEventType;
|
|
85
86
|
positionChanged: EventTypeWithValue;
|
|
87
|
+
bufferEnded: OnBufferEndEventType;
|
|
86
88
|
audioError: EventEmptyType; // to change
|
|
87
89
|
systemStateChanged: EventEmptyType; // to change
|
|
88
90
|
recorderError: OnRecorderErrorEventType;
|
package/src/interfaces.ts
CHANGED
|
@@ -229,6 +229,9 @@ export interface IAudioBufferQueueSourceNode
|
|
|
229
229
|
enqueueBuffer: (audioBuffer: IAudioBuffer) => string;
|
|
230
230
|
start: (when?: number, offset?: number) => void;
|
|
231
231
|
pause: () => void;
|
|
232
|
+
|
|
233
|
+
// passing subscriptionId(uint_64 in cpp, string in js) to the cpp
|
|
234
|
+
onBufferEnded: string;
|
|
232
235
|
}
|
|
233
236
|
|
|
234
237
|
export interface IConvolverNode extends IAudioNode {
|
|
@@ -6,6 +6,11 @@ import { AudioDevicesInfo, PermissionStatus } from '../system/types';
|
|
|
6
6
|
type OptionsMap = { [key: string]: string | boolean | number | undefined };
|
|
7
7
|
type NotificationOpResponse = { success: boolean; error?: string };
|
|
8
8
|
type NotificationType = 'playback' | 'recording' | 'simple';
|
|
9
|
+
type AudioFocusType =
|
|
10
|
+
| 'gain'
|
|
11
|
+
| 'gainTransient'
|
|
12
|
+
| 'gainTransientExclusive'
|
|
13
|
+
| 'gainTransientMayDuck';
|
|
9
14
|
|
|
10
15
|
interface Spec extends TurboModule {
|
|
11
16
|
install(): boolean;
|
|
@@ -22,7 +27,7 @@ interface Spec extends TurboModule {
|
|
|
22
27
|
disableSessionManagement(): void;
|
|
23
28
|
|
|
24
29
|
// Remote commands, system events and interruptions
|
|
25
|
-
observeAudioInterruptions(enabled: boolean): void;
|
|
30
|
+
observeAudioInterruptions(focusType: AudioFocusType, enabled: boolean): void;
|
|
26
31
|
activelyReclaimSession(enabled: boolean): void;
|
|
27
32
|
observeVolumeChanges(enabled: boolean): void;
|
|
28
33
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { TurboModule } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AudioDevicesInfo,
|
|
4
|
+
AudioFocusType,
|
|
5
|
+
PermissionStatus,
|
|
6
|
+
} from '../system/types';
|
|
3
7
|
|
|
4
8
|
// copy of spec from NativeAudioAPIModule.ts
|
|
5
9
|
type OptionsMap = {
|
|
@@ -23,7 +27,7 @@ interface Spec extends TurboModule {
|
|
|
23
27
|
disableSessionManagement(): void;
|
|
24
28
|
|
|
25
29
|
// Remote commands, system events and interruptions
|
|
26
|
-
observeAudioInterruptions(enabled: boolean): void;
|
|
30
|
+
observeAudioInterruptions(focusType: AudioFocusType, enabled: boolean): void;
|
|
27
31
|
activelyReclaimSession(enabled: boolean): void;
|
|
28
32
|
observeVolumeChanges(enabled: boolean): void;
|
|
29
33
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
IAudioManager,
|
|
8
8
|
PermissionStatus,
|
|
9
9
|
SessionOptions,
|
|
10
|
+
AudioFocusType,
|
|
10
11
|
} from './types';
|
|
11
12
|
|
|
12
13
|
class AudioManager implements IAudioManager {
|
|
@@ -43,8 +44,13 @@ class AudioManager implements IAudioManager {
|
|
|
43
44
|
NativeAudioAPIModule.disableSessionManagement();
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
observeAudioInterruptions(
|
|
47
|
-
|
|
47
|
+
observeAudioInterruptions(param: AudioFocusType | boolean | null) {
|
|
48
|
+
if (typeof param === 'string') {
|
|
49
|
+
NativeAudioAPIModule.observeAudioInterruptions(param, true);
|
|
50
|
+
} else {
|
|
51
|
+
// audiofocusgain as default value if not provided
|
|
52
|
+
NativeAudioAPIModule.observeAudioInterruptions('gain', param === true);
|
|
53
|
+
}
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
/**
|
package/src/system/types.ts
CHANGED
|
@@ -30,6 +30,12 @@ export type IOSOption =
|
|
|
30
30
|
| 'overrideMutedMicrophoneInterruption'
|
|
31
31
|
| 'interruptSpokenAudioAndMixWithOthers';
|
|
32
32
|
|
|
33
|
+
export type AudioFocusType =
|
|
34
|
+
| 'gain'
|
|
35
|
+
| 'gainTransient'
|
|
36
|
+
| 'gainTransientExclusive'
|
|
37
|
+
| 'gainTransientMayDuck';
|
|
38
|
+
|
|
33
39
|
export interface SessionOptions {
|
|
34
40
|
iosMode?: IOSMode;
|
|
35
41
|
iosOptions?: IOSOption[];
|
|
@@ -60,7 +66,7 @@ export interface IAudioManager {
|
|
|
60
66
|
disableSessionManagement(): void;
|
|
61
67
|
observeAudioInterruptions(enabled: boolean): void;
|
|
62
68
|
activelyReclaimSession(enabled: boolean): void;
|
|
63
|
-
|
|
69
|
+
observeAudioInterruptions(param: AudioFocusType | boolean | null): void;
|
|
64
70
|
addSystemEventListener<Name extends SystemEventName>(
|
|
65
71
|
name: Name,
|
|
66
72
|
callback: SystemEventCallback<Name>
|
|
@@ -4,6 +4,7 @@ import { RangeError, InvalidStateError } from '../errors';
|
|
|
4
4
|
|
|
5
5
|
export default class AudioScheduledSourceNode extends AudioNode {
|
|
6
6
|
protected hasBeenStarted: boolean = false;
|
|
7
|
+
private onEndedCallback?: (event: EventEmptyType) => void;
|
|
7
8
|
|
|
8
9
|
public start(when: number = 0): void {
|
|
9
10
|
if (when < 0) {
|
|
@@ -36,8 +37,12 @@ export default class AudioScheduledSourceNode extends AudioNode {
|
|
|
36
37
|
(this.node as globalThis.AudioScheduledSourceNode).stop(when);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
public get onEnded(): ((event: EventEmptyType) => void) | undefined {
|
|
41
|
+
return this.onEndedCallback;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
public set onEnded(callback: (event: EventEmptyType) => void | null) {
|
|
41
45
|
(this.node as globalThis.AudioScheduledSourceNode).onended = callback;
|
|
46
|
+
this.onEndedCallback = callback;
|
|
42
47
|
}
|
|
43
48
|
}
|