react-native-audio-api 0.11.0-nightly-db51488-20251208 → 0.11.0-nightly-6ba0571-20251209
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 +8 -23
- package/android/src/main/java/com/swmansion/audioapi/system/CentralizedForegroundService.kt +127 -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 +668 -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 +43 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/SimpleNotification.kt +119 -0
- package/ios/audioapi/ios/AudioAPIModule.h +2 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +108 -18
- package/ios/audioapi/ios/system/AudioEngine.mm +2 -2
- package/ios/audioapi/ios/system/AudioSessionManager.mm +1 -1
- 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 +59 -10
- 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/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 +5 -1
- 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/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 +3 -1
- 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 +4 -18
- 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/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 -2
- package/src/api.web.ts +7 -2
- package/src/events/types.ts +4 -20
- 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 +110 -0
- package/src/system/types.ts +0 -18
- 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
- package/ios/audioapi/ios/system/LockScreenManager.h +0 -23
- package/ios/audioapi/ios/system/LockScreenManager.mm +0 -314
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { NativeAudioAPIModule } from '../../specs';
|
|
2
|
+
import { AudioEventEmitter, AudioEventSubscription } from '../../events';
|
|
3
|
+
import type { NotificationManager, SimpleNotificationOptions } from './types';
|
|
4
|
+
|
|
5
|
+
/// Simple notification manager for basic notifications with title and text.
|
|
6
|
+
/// Implements the generic NotificationManager interface.
|
|
7
|
+
// It is only a showcase
|
|
8
|
+
class SimpleNotificationManager
|
|
9
|
+
implements
|
|
10
|
+
NotificationManager<
|
|
11
|
+
SimpleNotificationOptions,
|
|
12
|
+
SimpleNotificationOptions,
|
|
13
|
+
never
|
|
14
|
+
>
|
|
15
|
+
{
|
|
16
|
+
private notificationKey = 'simple';
|
|
17
|
+
private isRegistered = false;
|
|
18
|
+
private isShown = false;
|
|
19
|
+
private audioEventEmitter: AudioEventEmitter;
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
this.audioEventEmitter = new AudioEventEmitter(global.AudioEventEmitter);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// Register the simple notification (must be called before showing).
|
|
26
|
+
async register(): Promise<void> {
|
|
27
|
+
if (this.isRegistered) {
|
|
28
|
+
console.warn('SimpleNotification is already registered');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!NativeAudioAPIModule) {
|
|
33
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const result = await NativeAudioAPIModule.registerNotification(
|
|
37
|
+
'simple',
|
|
38
|
+
this.notificationKey
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (result.error) {
|
|
42
|
+
throw new Error(result.error);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.isRegistered = true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// Show the notification with initial options.
|
|
49
|
+
async show(options: SimpleNotificationOptions): Promise<void> {
|
|
50
|
+
if (!this.isRegistered) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
'SimpleNotification must be registered before showing. Call register() first.'
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!NativeAudioAPIModule) {
|
|
57
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const result = await NativeAudioAPIModule.showNotification(
|
|
61
|
+
this.notificationKey,
|
|
62
|
+
options as Record<string, string | number | boolean | undefined>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (result.error) {
|
|
66
|
+
throw new Error(result.error);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.isShown = true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// Update the notification with new options.
|
|
73
|
+
async update(options: SimpleNotificationOptions): Promise<void> {
|
|
74
|
+
if (!this.isShown) {
|
|
75
|
+
console.warn('SimpleNotification is not shown. Call show() first.');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!NativeAudioAPIModule) {
|
|
80
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const result = await NativeAudioAPIModule.updateNotification(
|
|
84
|
+
this.notificationKey,
|
|
85
|
+
options as Record<string, string | number | boolean | undefined>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (result.error) {
|
|
89
|
+
throw new Error(result.error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// Hide the notification (can be shown again later).
|
|
94
|
+
async hide(): Promise<void> {
|
|
95
|
+
if (!this.isShown) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!NativeAudioAPIModule) {
|
|
100
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const result = await NativeAudioAPIModule.hideNotification(
|
|
104
|
+
this.notificationKey
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
if (result.error) {
|
|
108
|
+
throw new Error(result.error);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.isShown = false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// Unregister the notification (must register again to use).
|
|
115
|
+
async unregister(): Promise<void> {
|
|
116
|
+
if (!this.isRegistered) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (this.isShown) {
|
|
121
|
+
await this.hide();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!NativeAudioAPIModule) {
|
|
125
|
+
throw new Error('NativeAudioAPIModule is not available');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const result = await NativeAudioAPIModule.unregisterNotification(
|
|
129
|
+
this.notificationKey
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
if (result.error) {
|
|
133
|
+
throw new Error(result.error);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.isRegistered = false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// Check if the notification is currently active.
|
|
140
|
+
async isActive(): Promise<boolean> {
|
|
141
|
+
if (!NativeAudioAPIModule) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return await NativeAudioAPIModule.isNotificationActive(
|
|
146
|
+
this.notificationKey
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// Add an event listener (SimpleNotification doesn't emit events).
|
|
151
|
+
addEventListener<T extends never>(
|
|
152
|
+
_eventName: T,
|
|
153
|
+
_callback: (event: never) => void
|
|
154
|
+
): AudioEventSubscription {
|
|
155
|
+
// SimpleNotification doesn't emit events, return a no-op subscription
|
|
156
|
+
console.warn('SimpleNotification does not support event listeners');
|
|
157
|
+
return this.audioEventEmitter.addAudioEventListener(
|
|
158
|
+
// Using a valid event name for the no-op subscription
|
|
159
|
+
'playbackNotificationPlay',
|
|
160
|
+
() => {}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/// Remove an event listener.
|
|
165
|
+
removeEventListener(subscription: AudioEventSubscription): void {
|
|
166
|
+
subscription.remove();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export default new SimpleNotificationManager();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as PlaybackNotificationManager } from './PlaybackNotificationManager';
|
|
2
|
+
export { default as RecordingNotificationManager } from './RecordingNotificationManager';
|
|
3
|
+
export { default as SimpleNotificationManager } from './SimpleNotificationManager';
|
|
4
|
+
export * from './types';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { AudioEventSubscription } from '../../events';
|
|
2
|
+
import { EventEmptyType, EventTypeWithValue } from '../../events/types';
|
|
3
|
+
|
|
4
|
+
/// Generic notification manager interface that all notification managers should implement.
|
|
5
|
+
/// Provides a consistent API for managing notification lifecycle and events.
|
|
6
|
+
export interface NotificationManager<
|
|
7
|
+
TShowOptions,
|
|
8
|
+
TUpdateOptions,
|
|
9
|
+
TEventName extends NotificationEventName,
|
|
10
|
+
> {
|
|
11
|
+
/// Register the notification (must be called before showing).
|
|
12
|
+
register(): Promise<void>;
|
|
13
|
+
|
|
14
|
+
/// Show the notification with initial options.
|
|
15
|
+
show(options: TShowOptions): Promise<void>;
|
|
16
|
+
|
|
17
|
+
/// Update the notification with new options.
|
|
18
|
+
update(options: TUpdateOptions): Promise<void>;
|
|
19
|
+
|
|
20
|
+
/// Hide the notification (can be shown again later).
|
|
21
|
+
hide(): Promise<void>;
|
|
22
|
+
|
|
23
|
+
/// Unregister the notification (must register again to use).
|
|
24
|
+
unregister(): Promise<void>;
|
|
25
|
+
|
|
26
|
+
/// Check if the notification is currently active.
|
|
27
|
+
isActive(): Promise<boolean>;
|
|
28
|
+
|
|
29
|
+
/// Add an event listener for notification events.
|
|
30
|
+
addEventListener<T extends TEventName>(
|
|
31
|
+
eventName: T,
|
|
32
|
+
callback: NotificationCallback<T>
|
|
33
|
+
): AudioEventSubscription;
|
|
34
|
+
|
|
35
|
+
/// Remove an event listener.
|
|
36
|
+
removeEventListener(subscription: AudioEventSubscription): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Metadata and state information for playback notifications.
|
|
40
|
+
export interface PlaybackNotificationInfo {
|
|
41
|
+
title?: string;
|
|
42
|
+
artist?: string;
|
|
43
|
+
album?: string;
|
|
44
|
+
artwork?: string | { uri: string };
|
|
45
|
+
androidSmallIcon?: string | { uri: string };
|
|
46
|
+
duration?: number;
|
|
47
|
+
elapsedTime?: number;
|
|
48
|
+
speed?: number;
|
|
49
|
+
state?: 'playing' | 'paused';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Available playback control actions.
|
|
53
|
+
export type PlaybackControlName =
|
|
54
|
+
| 'play'
|
|
55
|
+
| 'pause'
|
|
56
|
+
| 'next'
|
|
57
|
+
| 'previous'
|
|
58
|
+
| 'skipForward'
|
|
59
|
+
| 'skipBackward'
|
|
60
|
+
| 'seekTo';
|
|
61
|
+
|
|
62
|
+
/// Event names for playback notification actions.
|
|
63
|
+
interface PlaybackNotificationEvent {
|
|
64
|
+
playbackNotificationPlay: EventEmptyType;
|
|
65
|
+
playbackNotificationPause: EventEmptyType;
|
|
66
|
+
playbackNotificationNext: EventEmptyType;
|
|
67
|
+
playbackNotificationPrevious: EventEmptyType;
|
|
68
|
+
playbackNotificationSkipForward: EventTypeWithValue;
|
|
69
|
+
playbackNotificationSkipBackward: EventTypeWithValue;
|
|
70
|
+
playbackNotificationSeekTo: EventTypeWithValue;
|
|
71
|
+
playbackNotificationDismissed: EventEmptyType;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type PlaybackNotificationEventName = keyof PlaybackNotificationEvent;
|
|
75
|
+
|
|
76
|
+
/// Metadata and state information for recording notifications.
|
|
77
|
+
export interface RecordingNotificationInfo {
|
|
78
|
+
title?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
artwork?: string | { uri: string };
|
|
81
|
+
state?: 'recording' | 'stopped';
|
|
82
|
+
control?: RecordingControlName;
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// Available recording control actions.
|
|
87
|
+
export type RecordingControlName = 'start' | 'stop';
|
|
88
|
+
|
|
89
|
+
/// Event names for recording notification actions.
|
|
90
|
+
interface RecordingNotificationEvent {
|
|
91
|
+
recordingNotificationStart: EventEmptyType;
|
|
92
|
+
recordingNotificationStop: EventEmptyType;
|
|
93
|
+
recordingNotificationDismissed: EventEmptyType;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type RecordingNotificationEventName = keyof RecordingNotificationEvent;
|
|
97
|
+
|
|
98
|
+
export type NotificationEvents = PlaybackNotificationEvent &
|
|
99
|
+
RecordingNotificationEvent;
|
|
100
|
+
export type NotificationEventName = keyof NotificationEvents;
|
|
101
|
+
|
|
102
|
+
export type NotificationCallback<Name extends NotificationEventName> = (
|
|
103
|
+
event: NotificationEvents[Name]
|
|
104
|
+
) => void;
|
|
105
|
+
|
|
106
|
+
/// Options for a simple notification with title and text.
|
|
107
|
+
export interface SimpleNotificationOptions {
|
|
108
|
+
title?: string;
|
|
109
|
+
text?: string;
|
|
110
|
+
}
|
package/src/system/types.ts
CHANGED
|
@@ -34,24 +34,6 @@ export interface SessionOptions {
|
|
|
34
34
|
iosAllowHaptics?: boolean;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export type MediaState = 'state_playing' | 'state_paused';
|
|
38
|
-
|
|
39
|
-
interface BaseLockScreenInfo {
|
|
40
|
-
[key: string]: string | boolean | number | undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface LockScreenInfo extends BaseLockScreenInfo {
|
|
44
|
-
title?: string;
|
|
45
|
-
artwork?: string;
|
|
46
|
-
artist?: string;
|
|
47
|
-
album?: string;
|
|
48
|
-
duration?: number;
|
|
49
|
-
description?: string; // android only
|
|
50
|
-
state?: MediaState;
|
|
51
|
-
speed?: number;
|
|
52
|
-
elapsedTime?: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
37
|
export type PermissionStatus = 'Undetermined' | 'Denied' | 'Granted';
|
|
56
38
|
|
|
57
39
|
export interface AudioDeviceInfo {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable no-useless-constructor */
|
|
3
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
4
|
+
|
|
5
|
+
import type { AudioEventSubscription } from '../../events';
|
|
6
|
+
import type {
|
|
7
|
+
NotificationManager,
|
|
8
|
+
PlaybackNotificationInfo,
|
|
9
|
+
PlaybackControlName,
|
|
10
|
+
PlaybackNotificationEventName,
|
|
11
|
+
NotificationEvents,
|
|
12
|
+
} from '../../system';
|
|
13
|
+
|
|
14
|
+
/// Mock Manager for playback notifications. Does nothing.
|
|
15
|
+
class PlaybackNotificationManager
|
|
16
|
+
implements
|
|
17
|
+
NotificationManager<
|
|
18
|
+
PlaybackNotificationInfo,
|
|
19
|
+
PlaybackNotificationInfo,
|
|
20
|
+
PlaybackNotificationEventName
|
|
21
|
+
>
|
|
22
|
+
{
|
|
23
|
+
private isRegistered = false;
|
|
24
|
+
private isShown = false;
|
|
25
|
+
|
|
26
|
+
constructor() {}
|
|
27
|
+
|
|
28
|
+
async register(): Promise<void> {}
|
|
29
|
+
|
|
30
|
+
async show(info: PlaybackNotificationInfo): Promise<void> {}
|
|
31
|
+
|
|
32
|
+
async update(info: PlaybackNotificationInfo): Promise<void> {}
|
|
33
|
+
|
|
34
|
+
async hide(): Promise<void> {}
|
|
35
|
+
|
|
36
|
+
async unregister(): Promise<void> {}
|
|
37
|
+
|
|
38
|
+
async enableControl(
|
|
39
|
+
control: PlaybackControlName,
|
|
40
|
+
enabled: boolean
|
|
41
|
+
): Promise<void> {}
|
|
42
|
+
|
|
43
|
+
async isActive(): Promise<boolean> {
|
|
44
|
+
return this.isShown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
addEventListener<T extends PlaybackNotificationEventName>(
|
|
48
|
+
eventName: T,
|
|
49
|
+
callback: (event: NotificationEvents[T]) => void
|
|
50
|
+
): AudioEventSubscription {
|
|
51
|
+
// dummy subscription object with a no-op remove method
|
|
52
|
+
return {
|
|
53
|
+
remove: () => {},
|
|
54
|
+
} as unknown as AudioEventSubscription;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
removeEventListener(subscription: AudioEventSubscription): void {}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default new PlaybackNotificationManager();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable no-useless-constructor */
|
|
3
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
4
|
+
|
|
5
|
+
import type { AudioEventSubscription } from '../../events';
|
|
6
|
+
import type {
|
|
7
|
+
NotificationManager,
|
|
8
|
+
RecordingNotificationInfo,
|
|
9
|
+
RecordingControlName,
|
|
10
|
+
RecordingNotificationEventName,
|
|
11
|
+
NotificationEvents,
|
|
12
|
+
} from '../../system';
|
|
13
|
+
|
|
14
|
+
/// Mock Manager for recording notifications. Does nothing.
|
|
15
|
+
class RecordingNotificationManager
|
|
16
|
+
implements
|
|
17
|
+
NotificationManager<
|
|
18
|
+
RecordingNotificationInfo,
|
|
19
|
+
RecordingNotificationInfo,
|
|
20
|
+
RecordingNotificationEventName
|
|
21
|
+
>
|
|
22
|
+
{
|
|
23
|
+
private isRegistered = false;
|
|
24
|
+
private isShown = false;
|
|
25
|
+
|
|
26
|
+
constructor() {}
|
|
27
|
+
|
|
28
|
+
async register(): Promise<void> {}
|
|
29
|
+
|
|
30
|
+
async show(info: RecordingNotificationInfo): Promise<void> {}
|
|
31
|
+
|
|
32
|
+
async update(info: RecordingNotificationInfo): Promise<void> {}
|
|
33
|
+
|
|
34
|
+
async hide(): Promise<void> {}
|
|
35
|
+
|
|
36
|
+
async unregister(): Promise<void> {}
|
|
37
|
+
|
|
38
|
+
async enableControl(
|
|
39
|
+
control: RecordingControlName,
|
|
40
|
+
enabled: boolean
|
|
41
|
+
): Promise<void> {}
|
|
42
|
+
|
|
43
|
+
async isActive(): Promise<boolean> {
|
|
44
|
+
return this.isShown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
addEventListener<T extends RecordingNotificationEventName>(
|
|
48
|
+
eventName: T,
|
|
49
|
+
callback: (event: NotificationEvents[T]) => void
|
|
50
|
+
): AudioEventSubscription {
|
|
51
|
+
// dummy subscription object with a no-op remove method
|
|
52
|
+
return {
|
|
53
|
+
remove: () => {},
|
|
54
|
+
} as unknown as AudioEventSubscription;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
removeEventListener(subscription: AudioEventSubscription): void {}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default new RecordingNotificationManager();
|