react-native-audio-api 0.11.0-alpha.4 → 0.11.0-alpha.5
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 +164 -16
- package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioPlayer.kt +10 -8
- package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioRecorder.kt +10 -8
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +3 -4
- package/android/src/main/java/com/swmansion/audioapi/system/CentralizedForegroundService.kt +128 -0
- package/android/src/main/java/com/swmansion/audioapi/system/ForegroundServiceManager.kt +116 -0
- package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +115 -107
- package/android/src/main/java/com/swmansion/audioapi/system/PermissionRequestListener.kt +2 -1
- package/android/src/main/java/com/swmansion/audioapi/system/notification/BaseNotification.kt +47 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/NotificationRegistry.kt +191 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotification.kt +669 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotificationReceiver.kt +33 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotification.kt +303 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotificationReceiver.kt +45 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/SimpleNotification.kt +119 -0
- package/common/cpp/audioapi/utils/AudioFileProperties.h +17 -17
- package/ios/audioapi/ios/AudioAPIModule.h +2 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +108 -18
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +8 -1
- package/ios/audioapi/ios/system/AudioEngine.mm +2 -2
- package/ios/audioapi/ios/system/AudioSessionManager.mm +12 -9
- package/ios/audioapi/ios/system/NotificationManager.mm +1 -1
- package/ios/audioapi/ios/system/notification/BaseNotification.h +58 -0
- package/ios/audioapi/ios/system/notification/NotificationRegistry.h +70 -0
- package/ios/audioapi/ios/system/notification/NotificationRegistry.mm +172 -0
- package/ios/audioapi/ios/system/notification/PlaybackNotification.h +27 -0
- package/ios/audioapi/ios/system/notification/PlaybackNotification.mm +427 -0
- package/lib/commonjs/api.js +72 -1
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +27 -14
- package/lib/commonjs/api.web.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/commonjs/system/AudioManager.js +6 -9
- package/lib/commonjs/system/AudioManager.js.map +1 -1
- package/lib/commonjs/system/index.js +13 -0
- package/lib/commonjs/system/index.js.map +1 -1
- package/lib/commonjs/system/notification/PlaybackNotificationManager.js +135 -0
- package/lib/commonjs/system/notification/PlaybackNotificationManager.js.map +1 -0
- package/lib/commonjs/system/notification/RecordingNotificationManager.js +182 -0
- package/lib/commonjs/system/notification/RecordingNotificationManager.js.map +1 -0
- package/lib/commonjs/system/notification/SimpleNotificationManager.js +122 -0
- package/lib/commonjs/system/notification/SimpleNotificationManager.js.map +1 -0
- package/lib/commonjs/system/notification/index.js +45 -0
- package/lib/commonjs/system/notification/index.js.map +1 -0
- package/lib/commonjs/system/notification/types.js +6 -0
- package/lib/commonjs/system/notification/types.js.map +1 -0
- package/lib/commonjs/types.js +17 -17
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/web-system/index.js +17 -0
- package/lib/commonjs/web-system/index.js.map +1 -0
- package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js +34 -0
- package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js.map +1 -0
- package/lib/commonjs/web-system/notification/RecordingNotificationManager.js +34 -0
- package/lib/commonjs/web-system/notification/RecordingNotificationManager.js.map +1 -0
- package/lib/commonjs/web-system/notification/index.js +21 -0
- package/lib/commonjs/web-system/notification/index.js.map +1 -0
- package/lib/module/api.js +4 -0
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +3 -1
- package/lib/module/api.web.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/module/system/AudioManager.js +6 -9
- package/lib/module/system/AudioManager.js.map +1 -1
- package/lib/module/system/index.js +1 -0
- package/lib/module/system/index.js.map +1 -1
- package/lib/module/system/notification/PlaybackNotificationManager.js +131 -0
- package/lib/module/system/notification/PlaybackNotificationManager.js.map +1 -0
- package/lib/module/system/notification/RecordingNotificationManager.js +178 -0
- package/lib/module/system/notification/RecordingNotificationManager.js.map +1 -0
- package/lib/module/system/notification/SimpleNotificationManager.js +118 -0
- package/lib/module/system/notification/SimpleNotificationManager.js.map +1 -0
- package/lib/module/system/notification/index.js +7 -0
- package/lib/module/system/notification/index.js.map +1 -0
- package/lib/module/system/notification/types.js +4 -0
- package/lib/module/system/notification/types.js.map +1 -0
- package/lib/module/types.js +17 -17
- package/lib/module/types.js.map +1 -1
- package/lib/module/web-system/index.js +4 -0
- package/lib/module/web-system/index.js.map +1 -0
- package/lib/module/web-system/notification/PlaybackNotificationManager.js +30 -0
- package/lib/module/web-system/notification/PlaybackNotificationManager.js.map +1 -0
- package/lib/module/web-system/notification/RecordingNotificationManager.js +30 -0
- package/lib/module/web-system/notification/RecordingNotificationManager.js.map +1 -0
- package/lib/module/web-system/notification/index.js +5 -0
- package/lib/module/web-system/notification/index.js.map +1 -0
- package/lib/typescript/api.d.ts +2 -0
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +3 -1
- package/lib/typescript/api.web.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +3 -3
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts +16 -5
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
- package/lib/typescript/system/AudioManager.d.ts +4 -5
- package/lib/typescript/system/AudioManager.d.ts.map +1 -1
- package/lib/typescript/system/index.d.ts +1 -0
- package/lib/typescript/system/index.d.ts.map +1 -1
- package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts +22 -0
- package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts.map +1 -0
- package/lib/typescript/system/notification/RecordingNotificationManager.d.ts +23 -0
- package/lib/typescript/system/notification/RecordingNotificationManager.d.ts.map +1 -0
- package/lib/typescript/system/notification/SimpleNotificationManager.d.ts +20 -0
- package/lib/typescript/system/notification/SimpleNotificationManager.d.ts.map +1 -0
- package/lib/typescript/system/notification/index.d.ts +5 -0
- package/lib/typescript/system/notification/index.d.ts.map +1 -0
- package/lib/typescript/system/notification/types.d.ts +65 -0
- package/lib/typescript/system/notification/types.d.ts.map +1 -0
- package/lib/typescript/system/types.d.ts +0 -16
- package/lib/typescript/system/types.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +16 -16
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/web-system/index.d.ts +2 -0
- package/lib/typescript/web-system/index.d.ts.map +1 -0
- package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts +19 -0
- package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts.map +1 -0
- package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts +19 -0
- package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts.map +1 -0
- package/lib/typescript/web-system/notification/index.d.ts +3 -0
- package/lib/typescript/web-system/notification/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/api.ts +17 -0
- package/src/api.web.ts +7 -2
- package/src/events/types.ts +3 -4
- package/src/specs/NativeAudioAPIModule.ts +23 -7
- package/src/system/AudioManager.ts +10 -23
- package/src/system/index.ts +1 -0
- package/src/system/notification/PlaybackNotificationManager.ts +193 -0
- package/src/system/notification/RecordingNotificationManager.ts +242 -0
- package/src/system/notification/SimpleNotificationManager.ts +170 -0
- package/src/system/notification/index.ts +4 -0
- package/src/system/notification/types.ts +111 -0
- package/src/system/types.ts +0 -18
- package/src/types.ts +17 -17
- package/src/web-system/index.ts +1 -0
- package/src/web-system/notification/PlaybackNotificationManager.ts +60 -0
- package/src/web-system/notification/RecordingNotificationManager.ts +60 -0
- package/src/web-system/notification/index.ts +2 -0
- package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +0 -347
- package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +0 -273
- package/android/src/main/java/com/swmansion/audioapi/system/MediaReceiver.kt +0 -57
- package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionCallback.kt +0 -61
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AudioEventSubscription } from '../../events';
|
|
2
|
+
import { EventEmptyType, EventTypeWithValue } from '../../events/types';
|
|
3
|
+
export interface NotificationManager<TShowOptions, TUpdateOptions, TEventName extends NotificationEventName> {
|
|
4
|
+
register(): Promise<void>;
|
|
5
|
+
show(options: TShowOptions): Promise<void>;
|
|
6
|
+
update(options: TUpdateOptions): Promise<void>;
|
|
7
|
+
hide(): Promise<void>;
|
|
8
|
+
unregister(): Promise<void>;
|
|
9
|
+
isActive(): Promise<boolean>;
|
|
10
|
+
addEventListener<T extends TEventName>(eventName: T, callback: NotificationCallback<T>): AudioEventSubscription;
|
|
11
|
+
removeEventListener(subscription: AudioEventSubscription): void;
|
|
12
|
+
}
|
|
13
|
+
export interface PlaybackNotificationInfo {
|
|
14
|
+
title?: string;
|
|
15
|
+
artist?: string;
|
|
16
|
+
album?: string;
|
|
17
|
+
artwork?: string | {
|
|
18
|
+
uri: string;
|
|
19
|
+
};
|
|
20
|
+
androidSmallIcon?: string | {
|
|
21
|
+
uri: string;
|
|
22
|
+
};
|
|
23
|
+
duration?: number;
|
|
24
|
+
elapsedTime?: number;
|
|
25
|
+
speed?: number;
|
|
26
|
+
state?: 'playing' | 'paused';
|
|
27
|
+
}
|
|
28
|
+
export type PlaybackControlName = 'play' | 'pause' | 'next' | 'previous' | 'skipForward' | 'skipBackward' | 'seekTo';
|
|
29
|
+
interface PlaybackNotificationEvent {
|
|
30
|
+
playbackNotificationPlay: EventEmptyType;
|
|
31
|
+
playbackNotificationPause: EventEmptyType;
|
|
32
|
+
playbackNotificationNext: EventEmptyType;
|
|
33
|
+
playbackNotificationPrevious: EventEmptyType;
|
|
34
|
+
playbackNotificationSkipForward: EventTypeWithValue;
|
|
35
|
+
playbackNotificationSkipBackward: EventTypeWithValue;
|
|
36
|
+
playbackNotificationSeekTo: EventTypeWithValue;
|
|
37
|
+
playbackNotificationDismissed: EventEmptyType;
|
|
38
|
+
}
|
|
39
|
+
export type PlaybackNotificationEventName = keyof PlaybackNotificationEvent;
|
|
40
|
+
export interface RecordingNotificationInfo {
|
|
41
|
+
title?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
artwork?: string | {
|
|
44
|
+
uri: string;
|
|
45
|
+
};
|
|
46
|
+
state?: 'recording' | 'stopped';
|
|
47
|
+
control?: RecordingControlName;
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export type RecordingControlName = 'start' | 'stop';
|
|
51
|
+
interface RecordingNotificationEvent {
|
|
52
|
+
recordingNotificationStart: EventEmptyType;
|
|
53
|
+
recordingNotificationStop: EventEmptyType;
|
|
54
|
+
recordingNotificationDismissed: EventEmptyType;
|
|
55
|
+
}
|
|
56
|
+
export type RecordingNotificationEventName = keyof RecordingNotificationEvent;
|
|
57
|
+
export type NotificationEvents = PlaybackNotificationEvent & RecordingNotificationEvent;
|
|
58
|
+
export type NotificationEventName = keyof NotificationEvents;
|
|
59
|
+
export type NotificationCallback<Name extends NotificationEventName> = (event: NotificationEvents[Name]) => void;
|
|
60
|
+
export interface SimpleNotificationOptions {
|
|
61
|
+
title?: string;
|
|
62
|
+
text?: string;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/system/notification/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,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AAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -7,21 +7,6 @@ export interface SessionOptions {
|
|
|
7
7
|
iosCategory?: IOSCategory;
|
|
8
8
|
iosAllowHaptics?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export type MediaState = 'state_playing' | 'state_paused';
|
|
11
|
-
interface BaseLockScreenInfo {
|
|
12
|
-
[key: string]: string | boolean | number | undefined;
|
|
13
|
-
}
|
|
14
|
-
export interface LockScreenInfo extends BaseLockScreenInfo {
|
|
15
|
-
title?: string;
|
|
16
|
-
artwork?: string;
|
|
17
|
-
artist?: string;
|
|
18
|
-
album?: string;
|
|
19
|
-
duration?: number;
|
|
20
|
-
description?: string;
|
|
21
|
-
state?: MediaState;
|
|
22
|
-
speed?: number;
|
|
23
|
-
elapsedTime?: number;
|
|
24
|
-
}
|
|
25
10
|
export type PermissionStatus = 'Undetermined' | 'Denied' | 'Granted';
|
|
26
11
|
export interface AudioDeviceInfo {
|
|
27
12
|
name: string;
|
|
@@ -34,5 +19,4 @@ export interface AudioDevicesInfo {
|
|
|
34
19
|
currentInputs: AudioDeviceList;
|
|
35
20
|
currentOutputs: AudioDeviceList;
|
|
36
21
|
}
|
|
37
|
-
export {};
|
|
38
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/system/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,SAAS,GACT,UAAU,GACV,YAAY,GACZ,aAAa,GACb,eAAe,CAAC;AAEpB,MAAM,MAAM,OAAO,GACf,SAAS,GACT,UAAU,GACV,WAAW,GACX,WAAW,GACX,aAAa,GACb,aAAa,GACb,aAAa,GACb,eAAe,GACf,gBAAgB,CAAC;AAErB,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,cAAc,GACd,eAAe,GACf,gBAAgB,GAChB,kBAAkB,GAClB,o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;CACjC"}
|
|
@@ -23,21 +23,26 @@ export interface OfflineAudioContextOptions {
|
|
|
23
23
|
sampleRate: number;
|
|
24
24
|
}
|
|
25
25
|
export declare enum FileDirectory {
|
|
26
|
-
Document =
|
|
27
|
-
Cache =
|
|
26
|
+
Document = 0,
|
|
27
|
+
Cache = 1
|
|
28
28
|
}
|
|
29
29
|
export declare enum FileFormat {
|
|
30
|
-
Wav =
|
|
31
|
-
Caf =
|
|
32
|
-
M4A =
|
|
33
|
-
Flac =
|
|
30
|
+
Wav = 0,
|
|
31
|
+
Caf = 1,
|
|
32
|
+
M4A = 2,
|
|
33
|
+
Flac = 3
|
|
34
34
|
}
|
|
35
35
|
export declare enum IOSAudioQuality {
|
|
36
|
-
Min =
|
|
37
|
-
Low =
|
|
38
|
-
Medium =
|
|
39
|
-
High =
|
|
40
|
-
Max =
|
|
36
|
+
Min = 0,
|
|
37
|
+
Low = 1,
|
|
38
|
+
Medium = 2,
|
|
39
|
+
High = 3,
|
|
40
|
+
Max = 4
|
|
41
|
+
}
|
|
42
|
+
export declare enum BitDepth {
|
|
43
|
+
Bit16 = 0,
|
|
44
|
+
Bit24 = 1,
|
|
45
|
+
Bit32 = 2
|
|
41
46
|
}
|
|
42
47
|
export declare enum FlacCompressionLevel {
|
|
43
48
|
L0 = 0,
|
|
@@ -50,11 +55,6 @@ export declare enum FlacCompressionLevel {
|
|
|
50
55
|
L7 = 7,
|
|
51
56
|
L8 = 8
|
|
52
57
|
}
|
|
53
|
-
export declare enum BitDepth {
|
|
54
|
-
Bit16 = 1,
|
|
55
|
-
Bit24 = 2,
|
|
56
|
-
Bit32 = 3
|
|
57
|
-
}
|
|
58
58
|
export interface FilePresetType {
|
|
59
59
|
bitRate: number;
|
|
60
60
|
sampleRate: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C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CAAC;IAEnB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web-system/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AudioEventSubscription } from '../../events';
|
|
2
|
+
import type { NotificationManager, PlaybackNotificationInfo, PlaybackControlName, PlaybackNotificationEventName, NotificationEvents } from '../../system';
|
|
3
|
+
declare class PlaybackNotificationManager implements NotificationManager<PlaybackNotificationInfo, PlaybackNotificationInfo, PlaybackNotificationEventName> {
|
|
4
|
+
private isRegistered;
|
|
5
|
+
private isShown;
|
|
6
|
+
constructor();
|
|
7
|
+
register(): Promise<void>;
|
|
8
|
+
show(info: PlaybackNotificationInfo): Promise<void>;
|
|
9
|
+
update(info: PlaybackNotificationInfo): Promise<void>;
|
|
10
|
+
hide(): Promise<void>;
|
|
11
|
+
unregister(): Promise<void>;
|
|
12
|
+
enableControl(control: PlaybackControlName, enabled: boolean): Promise<void>;
|
|
13
|
+
isActive(): Promise<boolean>;
|
|
14
|
+
addEventListener<T extends PlaybackNotificationEventName>(eventName: T, callback: (event: NotificationEvents[T]) => void): AudioEventSubscription;
|
|
15
|
+
removeEventListener(subscription: AudioEventSubscription): void;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: PlaybackNotificationManager;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=PlaybackNotificationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaybackNotificationManager.d.ts","sourceRoot":"","sources":["../../../../src/web-system/notification/PlaybackNotificationManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAGtB,cAAM,2BACJ,YACE,mBAAmB,CACjB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,CAC9B;IAEH,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAS;;IAIlB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzB,IAAI,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnD,MAAM,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAErD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAErB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,aAAa,CACjB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;IAEV,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,gBAAgB,CAAC,CAAC,SAAS,6BAA6B,EACtD,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,sBAAsB;IAOzB,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,GAAG,IAAI;CAChE;;AAED,wBAAiD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AudioEventSubscription } from '../../events';
|
|
2
|
+
import type { NotificationManager, RecordingNotificationInfo, RecordingControlName, RecordingNotificationEventName, NotificationEvents } from '../../system';
|
|
3
|
+
declare class RecordingNotificationManager implements NotificationManager<RecordingNotificationInfo, RecordingNotificationInfo, RecordingNotificationEventName> {
|
|
4
|
+
private isRegistered;
|
|
5
|
+
private isShown;
|
|
6
|
+
constructor();
|
|
7
|
+
register(): Promise<void>;
|
|
8
|
+
show(info: RecordingNotificationInfo): Promise<void>;
|
|
9
|
+
update(info: RecordingNotificationInfo): Promise<void>;
|
|
10
|
+
hide(): Promise<void>;
|
|
11
|
+
unregister(): Promise<void>;
|
|
12
|
+
enableControl(control: RecordingControlName, enabled: boolean): Promise<void>;
|
|
13
|
+
isActive(): Promise<boolean>;
|
|
14
|
+
addEventListener<T extends RecordingNotificationEventName>(eventName: T, callback: (event: NotificationEvents[T]) => void): AudioEventSubscription;
|
|
15
|
+
removeEventListener(subscription: AudioEventSubscription): void;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: RecordingNotificationManager;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=RecordingNotificationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordingNotificationManager.d.ts","sourceRoot":"","sources":["../../../../src/web-system/notification/RecordingNotificationManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,8BAA8B,EAC9B,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAGtB,cAAM,4BACJ,YACE,mBAAmB,CACjB,yBAAyB,EACzB,yBAAyB,EACzB,8BAA8B,CAC/B;IAEH,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAS;;IAIlB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzB,IAAI,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEpD,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAErB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,aAAa,CACjB,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;IAEV,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,gBAAgB,CAAC,CAAC,SAAS,8BAA8B,EACvD,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,sBAAsB;IAOzB,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,GAAG,IAAI;CAChE;;AAED,wBAAkD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web-system/notification/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.11.0-alpha.
|
|
3
|
+
"version": "0.11.0-alpha.5",
|
|
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"
|
package/src/api.ts
CHANGED
|
@@ -33,3 +33,20 @@ export * from './errors';
|
|
|
33
33
|
export * from './system/types';
|
|
34
34
|
export * from './types';
|
|
35
35
|
export { default as FilePreset } from './utils/filePresets';
|
|
36
|
+
|
|
37
|
+
// Notification System
|
|
38
|
+
export {
|
|
39
|
+
PlaybackNotificationManager,
|
|
40
|
+
RecordingNotificationManager,
|
|
41
|
+
} from './system/notification';
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
NotificationManager,
|
|
45
|
+
PlaybackControlName,
|
|
46
|
+
PlaybackNotificationEventName,
|
|
47
|
+
PlaybackNotificationInfo,
|
|
48
|
+
RecordingControlName,
|
|
49
|
+
RecordingNotificationEventName,
|
|
50
|
+
RecordingNotificationInfo,
|
|
51
|
+
SimpleNotificationOptions,
|
|
52
|
+
} from './system/notification';
|
package/src/api.web.ts
CHANGED
|
@@ -32,11 +32,16 @@ export {
|
|
|
32
32
|
IOSMode,
|
|
33
33
|
IOSOption,
|
|
34
34
|
SessionOptions,
|
|
35
|
-
MediaState,
|
|
36
|
-
LockScreenInfo,
|
|
37
35
|
PermissionStatus,
|
|
38
36
|
} from './system/types';
|
|
39
37
|
|
|
38
|
+
export {
|
|
39
|
+
PlaybackNotificationManager,
|
|
40
|
+
RecordingNotificationManager,
|
|
41
|
+
} from './web-system';
|
|
42
|
+
|
|
43
|
+
export * from './system/notification/types';
|
|
44
|
+
|
|
40
45
|
export {
|
|
41
46
|
IndexSizeError,
|
|
42
47
|
InvalidAccessError,
|
package/src/events/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AudioBuffer from '../core/AudioBuffer';
|
|
2
|
+
import { NotificationEvents } from '../system';
|
|
2
3
|
|
|
3
4
|
export interface EventEmptyType {}
|
|
4
5
|
|
|
@@ -8,7 +9,7 @@ export interface EventTypeWithValue {
|
|
|
8
9
|
|
|
9
10
|
interface OnInterruptionEventType {
|
|
10
11
|
type: 'ended' | 'began';
|
|
11
|
-
|
|
12
|
+
isTransient: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
interface OnRouteChangeEventType {
|
|
@@ -87,9 +88,7 @@ interface AudioAPIEvents {
|
|
|
87
88
|
recorderError: OnRecorderErrorEventType;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
type AudioEvents = SystemEvents & AudioAPIEvents;
|
|
91
|
-
|
|
92
|
-
export type RemoteCommandEventName = keyof RemoteCommandEvents;
|
|
91
|
+
type AudioEvents = SystemEvents & AudioAPIEvents & NotificationEvents;
|
|
93
92
|
|
|
94
93
|
export type SystemEventName = keyof SystemEvents;
|
|
95
94
|
export type SystemEventCallback<Name extends SystemEventName> = (
|
|
@@ -3,6 +3,10 @@ import type { TurboModule } from 'react-native';
|
|
|
3
3
|
import { TurboModuleRegistry } from 'react-native';
|
|
4
4
|
import { AudioDevicesInfo, PermissionStatus } from '../system/types';
|
|
5
5
|
|
|
6
|
+
type OptionsMap = { [key: string]: string | boolean | number | undefined };
|
|
7
|
+
type NotificationOpResponse = { success: boolean; error?: string };
|
|
8
|
+
type NotificationType = 'playback' | 'recording' | 'simple';
|
|
9
|
+
|
|
6
10
|
interface Spec extends TurboModule {
|
|
7
11
|
install(): boolean;
|
|
8
12
|
getDevicePreferredSampleRate(): number;
|
|
@@ -17,14 +21,7 @@ interface Spec extends TurboModule {
|
|
|
17
21
|
): void;
|
|
18
22
|
disableSessionManagement(): void;
|
|
19
23
|
|
|
20
|
-
// Lock Screen Info
|
|
21
|
-
setLockScreenInfo(info: {
|
|
22
|
-
[key: string]: string | boolean | number | undefined;
|
|
23
|
-
}): void;
|
|
24
|
-
resetLockScreenInfo(): void;
|
|
25
|
-
|
|
26
24
|
// Remote commands, system events and interruptions
|
|
27
|
-
enableRemoteCommand(name: string, enabled: boolean): void;
|
|
28
25
|
observeAudioInterruptions(enabled: boolean): void;
|
|
29
26
|
activelyReclaimSession(enabled: boolean): void;
|
|
30
27
|
observeVolumeChanges(enabled: boolean): void;
|
|
@@ -32,9 +29,28 @@ interface Spec extends TurboModule {
|
|
|
32
29
|
// Permissions
|
|
33
30
|
requestRecordingPermissions(): Promise<PermissionStatus>;
|
|
34
31
|
checkRecordingPermissions(): Promise<PermissionStatus>;
|
|
32
|
+
requestNotificationPermissions(): Promise<PermissionStatus>;
|
|
33
|
+
checkNotificationPermissions(): Promise<PermissionStatus>;
|
|
35
34
|
|
|
36
35
|
// Audio devices
|
|
37
36
|
getDevicesInfo(): Promise<AudioDevicesInfo>;
|
|
37
|
+
|
|
38
|
+
// New notification system
|
|
39
|
+
registerNotification(
|
|
40
|
+
type: NotificationType,
|
|
41
|
+
key: string
|
|
42
|
+
): Promise<NotificationOpResponse>;
|
|
43
|
+
showNotification(
|
|
44
|
+
key: string,
|
|
45
|
+
options: OptionsMap
|
|
46
|
+
): Promise<NotificationOpResponse>;
|
|
47
|
+
updateNotification(
|
|
48
|
+
key: string,
|
|
49
|
+
options: OptionsMap
|
|
50
|
+
): Promise<NotificationOpResponse>;
|
|
51
|
+
hideNotification(key: string): Promise<NotificationOpResponse>;
|
|
52
|
+
unregisterNotification(key: string): Promise<NotificationOpResponse>;
|
|
53
|
+
isNotificationActive(key: string): Promise<boolean>;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
const NativeAudioAPIModule = TurboModuleRegistry.get<Spec>('AudioAPIModule');
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
+
import { SessionOptions, PermissionStatus, AudioDevicesInfo } from './types';
|
|
2
|
+
import { SystemEventName, SystemEventCallback } from '../events/types';
|
|
1
3
|
import { AudioEventEmitter, AudioEventSubscription } from '../events';
|
|
2
|
-
import {
|
|
3
|
-
RemoteCommandEventName,
|
|
4
|
-
SystemEventCallback,
|
|
5
|
-
SystemEventName,
|
|
6
|
-
} from '../events/types';
|
|
7
4
|
import { NativeAudioAPIModule } from '../specs';
|
|
8
|
-
import {
|
|
9
|
-
AudioDevicesInfo,
|
|
10
|
-
LockScreenInfo,
|
|
11
|
-
PermissionStatus,
|
|
12
|
-
SessionOptions,
|
|
13
|
-
} from './types';
|
|
14
5
|
|
|
15
6
|
class AudioManager {
|
|
16
7
|
private readonly audioEventEmitter: AudioEventEmitter;
|
|
@@ -39,14 +30,6 @@ class AudioManager {
|
|
|
39
30
|
NativeAudioAPIModule!.disableSessionManagement();
|
|
40
31
|
}
|
|
41
32
|
|
|
42
|
-
setLockScreenInfo(info: LockScreenInfo) {
|
|
43
|
-
NativeAudioAPIModule!.setLockScreenInfo(info);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
resetLockScreenInfo() {
|
|
47
|
-
NativeAudioAPIModule!.resetLockScreenInfo();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
33
|
observeAudioInterruptions(enabled: boolean) {
|
|
51
34
|
NativeAudioAPIModule!.observeAudioInterruptions(enabled);
|
|
52
35
|
}
|
|
@@ -72,10 +55,6 @@ class AudioManager {
|
|
|
72
55
|
NativeAudioAPIModule!.observeVolumeChanges(enabled);
|
|
73
56
|
}
|
|
74
57
|
|
|
75
|
-
enableRemoteCommand(name: RemoteCommandEventName, enabled: boolean) {
|
|
76
|
-
NativeAudioAPIModule!.enableRemoteCommand(name, enabled);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
58
|
addSystemEventListener<Name extends SystemEventName>(
|
|
80
59
|
name: Name,
|
|
81
60
|
callback: SystemEventCallback<Name>
|
|
@@ -91,6 +70,14 @@ class AudioManager {
|
|
|
91
70
|
return NativeAudioAPIModule!.checkRecordingPermissions();
|
|
92
71
|
}
|
|
93
72
|
|
|
73
|
+
async requestNotificationPermissions(): Promise<PermissionStatus> {
|
|
74
|
+
return NativeAudioAPIModule!.requestNotificationPermissions();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async checkNotificationPermissions(): Promise<PermissionStatus> {
|
|
78
|
+
return NativeAudioAPIModule!.checkNotificationPermissions();
|
|
79
|
+
}
|
|
80
|
+
|
|
94
81
|
async getDevicesInfo(): Promise<AudioDevicesInfo> {
|
|
95
82
|
return NativeAudioAPIModule!.getDevicesInfo();
|
|
96
83
|
}
|
package/src/system/index.ts
CHANGED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { NativeAudioAPIModule } from '../../specs';
|
|
2
|
+
import { AudioEventEmitter, AudioEventSubscription } from '../../events';
|
|
3
|
+
import type {
|
|
4
|
+
NotificationManager,
|
|
5
|
+
PlaybackNotificationInfo,
|
|
6
|
+
PlaybackControlName,
|
|
7
|
+
PlaybackNotificationEventName,
|
|
8
|
+
NotificationEvents,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
/// Manager for media playback notifications with controls and MediaSession integration.
|
|
12
|
+
class PlaybackNotificationManager
|
|
13
|
+
implements
|
|
14
|
+
NotificationManager<
|
|
15
|
+
PlaybackNotificationInfo,
|
|
16
|
+
PlaybackNotificationInfo,
|
|
17
|
+
PlaybackNotificationEventName
|
|
18
|
+
>
|
|
19
|
+
{
|
|
20
|
+
private notificationKey = 'playback';
|
|
21
|
+
private isRegistered = false;
|
|
22
|
+
private isShown = false;
|
|
23
|
+
private audioEventEmitter: AudioEventEmitter;
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
this.audioEventEmitter = new AudioEventEmitter(global.AudioEventEmitter);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Register the playback notification (must be called before showing).
|
|
30
|
+
async register(): Promise<void> {
|
|
31
|
+
if (this.isRegistered) {
|
|
32
|
+
console.warn('PlaybackNotification is already registered');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!NativeAudioAPIModule) {
|
|
37
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const result = await NativeAudioAPIModule.registerNotification(
|
|
41
|
+
'playback',
|
|
42
|
+
this.notificationKey
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (result.error) {
|
|
46
|
+
throw new Error(result.error);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.isRegistered = true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Show the notification with initial metadata.
|
|
53
|
+
async show(info: PlaybackNotificationInfo): Promise<void> {
|
|
54
|
+
if (!this.isRegistered) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'PlaybackNotification must be registered before showing. Call register() first.'
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!NativeAudioAPIModule) {
|
|
61
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = await NativeAudioAPIModule.showNotification(
|
|
65
|
+
this.notificationKey,
|
|
66
|
+
info as Record<string, string | number | boolean | undefined>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (result.error) {
|
|
70
|
+
throw new Error(result.error);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this.isShown = true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// Update the notification with new metadata or state.
|
|
77
|
+
async update(info: PlaybackNotificationInfo): Promise<void> {
|
|
78
|
+
if (!this.isShown) {
|
|
79
|
+
console.warn('PlaybackNotification is not shown. Call show() first.');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!NativeAudioAPIModule) {
|
|
84
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const result = await NativeAudioAPIModule.updateNotification(
|
|
88
|
+
this.notificationKey,
|
|
89
|
+
info as Record<string, string | number | boolean | undefined>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
if (result.error) {
|
|
93
|
+
throw new Error(result.error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// Hide the notification (can be shown again later).
|
|
98
|
+
async hide(): Promise<void> {
|
|
99
|
+
if (!this.isShown) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!NativeAudioAPIModule) {
|
|
104
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const result = await NativeAudioAPIModule.hideNotification(
|
|
108
|
+
this.notificationKey
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
if (result.error) {
|
|
112
|
+
throw new Error(result.error);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.isShown = false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// Unregister the notification (must register again to use).
|
|
119
|
+
async unregister(): Promise<void> {
|
|
120
|
+
if (!this.isRegistered) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this.isShown) {
|
|
125
|
+
await this.hide();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!NativeAudioAPIModule) {
|
|
129
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const result = await NativeAudioAPIModule.unregisterNotification(
|
|
133
|
+
this.notificationKey
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (result.error) {
|
|
137
|
+
throw new Error(result.error);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.isRegistered = false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// Enable or disable a specific playback control.
|
|
144
|
+
async enableControl(
|
|
145
|
+
control: PlaybackControlName,
|
|
146
|
+
enabled: boolean
|
|
147
|
+
): Promise<void> {
|
|
148
|
+
if (!this.isRegistered) {
|
|
149
|
+
console.warn('PlaybackNotification is not registered');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!NativeAudioAPIModule) {
|
|
154
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const params = { control, enabled };
|
|
158
|
+
const result = await NativeAudioAPIModule.updateNotification(
|
|
159
|
+
this.notificationKey,
|
|
160
|
+
params as Record<string, string | number | boolean | undefined>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (result.error) {
|
|
164
|
+
throw new Error(result.error);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/// Check if the notification is currently active.
|
|
169
|
+
async isActive(): Promise<boolean> {
|
|
170
|
+
if (!NativeAudioAPIModule) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return await NativeAudioAPIModule.isNotificationActive(
|
|
175
|
+
this.notificationKey
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// Add an event listener for notification actions.
|
|
180
|
+
addEventListener<T extends PlaybackNotificationEventName>(
|
|
181
|
+
eventName: T,
|
|
182
|
+
callback: (event: NotificationEvents[T]) => void
|
|
183
|
+
): AudioEventSubscription {
|
|
184
|
+
return this.audioEventEmitter.addAudioEventListener(eventName, callback);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Remove an event listener. */
|
|
188
|
+
removeEventListener(subscription: AudioEventSubscription): void {
|
|
189
|
+
subscription.remove();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export default new PlaybackNotificationManager();
|