react-native-audio-api 0.11.0-alpha.6 → 0.11.0-alpha.7
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/lib/commonjs/system/notification/PlaybackNotificationManager.js +17 -14
- package/lib/commonjs/system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/commonjs/system/notification/RecordingNotificationManager.js +22 -19
- package/lib/commonjs/system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/commonjs/system/notification/SimpleNotificationManager.js +16 -13
- package/lib/commonjs/system/notification/SimpleNotificationManager.js.map +1 -1
- package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js +6 -3
- package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/commonjs/web-system/notification/RecordingNotificationManager.js +6 -3
- package/lib/commonjs/web-system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/module/system/notification/PlaybackNotificationManager.js +17 -14
- package/lib/module/system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/module/system/notification/RecordingNotificationManager.js +22 -19
- package/lib/module/system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/module/system/notification/SimpleNotificationManager.js +16 -13
- package/lib/module/system/notification/SimpleNotificationManager.js.map +1 -1
- package/lib/module/web-system/notification/PlaybackNotificationManager.js +6 -3
- package/lib/module/web-system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/module/web-system/notification/RecordingNotificationManager.js +6 -3
- package/lib/module/web-system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts +4 -3
- package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts.map +1 -1
- package/lib/typescript/system/notification/RecordingNotificationManager.d.ts +4 -3
- package/lib/typescript/system/notification/RecordingNotificationManager.d.ts.map +1 -1
- package/lib/typescript/system/notification/SimpleNotificationManager.d.ts +3 -2
- package/lib/typescript/system/notification/SimpleNotificationManager.d.ts.map +1 -1
- package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts +4 -3
- package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts.map +1 -1
- package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts +4 -3
- package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/system/notification/PlaybackNotificationManager.ts +20 -16
- package/src/system/notification/RecordingNotificationManager.ts +26 -21
- package/src/system/notification/SimpleNotificationManager.ts +18 -13
- package/src/web-system/notification/PlaybackNotificationManager.ts +9 -5
- package/src/web-system/notification/RecordingNotificationManager.ts +9 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import { NativeAudioAPIModule } from '../../specs';
|
|
3
2
|
import { AudioEventEmitter, AudioEventSubscription } from '../../events';
|
|
3
|
+
import { NativeAudioAPIModule } from '../../specs';
|
|
4
4
|
import type {
|
|
5
|
+
NotificationEvents,
|
|
5
6
|
NotificationManager,
|
|
6
|
-
RecordingNotificationInfo,
|
|
7
7
|
RecordingControlName,
|
|
8
8
|
RecordingNotificationEventName,
|
|
9
|
-
|
|
9
|
+
RecordingNotificationInfo,
|
|
10
10
|
} from './types';
|
|
11
11
|
|
|
12
12
|
/// Manager for recording notifications with controls.
|
|
@@ -18,9 +18,10 @@ class RecordingNotificationManager
|
|
|
18
18
|
RecordingNotificationEventName
|
|
19
19
|
>
|
|
20
20
|
{
|
|
21
|
+
private isRegistered_ = false;
|
|
22
|
+
private isShown_ = false;
|
|
23
|
+
|
|
21
24
|
private notificationKey = 'recording';
|
|
22
|
-
private isRegistered = false;
|
|
23
|
-
private isShown = false;
|
|
24
25
|
private audioEventEmitter: AudioEventEmitter;
|
|
25
26
|
private isIOS = Platform.OS === 'ios';
|
|
26
27
|
|
|
@@ -30,14 +31,14 @@ class RecordingNotificationManager
|
|
|
30
31
|
|
|
31
32
|
/// Register the recording notification (must be called before showing).
|
|
32
33
|
async register(): Promise<void> {
|
|
33
|
-
if (this.
|
|
34
|
+
if (this.isRegistered_) {
|
|
34
35
|
console.warn('RecordingNotification is already registered');
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
// Recording notifications are only supported on Android
|
|
39
40
|
if (this.isIOS) {
|
|
40
|
-
this.
|
|
41
|
+
this.isRegistered_ = true;
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -54,12 +55,12 @@ class RecordingNotificationManager
|
|
|
54
55
|
throw new Error(result.error);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
this.
|
|
58
|
+
this.isRegistered_ = true;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/// Show the notification with initial metadata.
|
|
61
62
|
async show(info: RecordingNotificationInfo): Promise<void> {
|
|
62
|
-
if (!this.
|
|
63
|
+
if (!this.isRegistered_) {
|
|
63
64
|
throw new Error(
|
|
64
65
|
'RecordingNotification must be registered before showing. Call register() first.'
|
|
65
66
|
);
|
|
@@ -67,7 +68,7 @@ class RecordingNotificationManager
|
|
|
67
68
|
|
|
68
69
|
// Recording notifications are only supported on Android
|
|
69
70
|
if (this.isIOS) {
|
|
70
|
-
this.
|
|
71
|
+
this.isShown_ = true;
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
|
|
@@ -84,12 +85,12 @@ class RecordingNotificationManager
|
|
|
84
85
|
throw new Error(result.error);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
this.
|
|
88
|
+
this.isShown_ = true;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
/// Update the notification with new metadata or state.
|
|
91
92
|
async update(info: RecordingNotificationInfo): Promise<void> {
|
|
92
|
-
if (!this.
|
|
93
|
+
if (!this.isShown_) {
|
|
93
94
|
console.warn('RecordingNotification is not shown. Call show() first.');
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
@@ -115,13 +116,13 @@ class RecordingNotificationManager
|
|
|
115
116
|
|
|
116
117
|
/// Hide the notification (can be shown again later).
|
|
117
118
|
async hide(): Promise<void> {
|
|
118
|
-
if (!this.
|
|
119
|
+
if (!this.isShown_) {
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// Recording notifications are only supported on Android
|
|
123
124
|
if (this.isIOS) {
|
|
124
|
-
this.
|
|
125
|
+
this.isShown_ = false;
|
|
125
126
|
return;
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -137,22 +138,22 @@ class RecordingNotificationManager
|
|
|
137
138
|
throw new Error(result.error);
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
this.
|
|
141
|
+
this.isShown_ = false;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
/// Unregister the notification (must register again to use).
|
|
144
145
|
async unregister(): Promise<void> {
|
|
145
|
-
if (!this.
|
|
146
|
+
if (!this.isRegistered_) {
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
if (this.
|
|
150
|
+
if (this.isShown_) {
|
|
150
151
|
await this.hide();
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
// Recording notifications are only supported on Android
|
|
154
155
|
if (this.isIOS) {
|
|
155
|
-
this.
|
|
156
|
+
this.isRegistered_ = false;
|
|
156
157
|
return;
|
|
157
158
|
}
|
|
158
159
|
|
|
@@ -168,7 +169,7 @@ class RecordingNotificationManager
|
|
|
168
169
|
throw new Error(result.error);
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
this.
|
|
172
|
+
this.isRegistered_ = false;
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
/// Enable or disable a specific recording control.
|
|
@@ -176,7 +177,7 @@ class RecordingNotificationManager
|
|
|
176
177
|
control: RecordingControlName,
|
|
177
178
|
enabled: boolean
|
|
178
179
|
): Promise<void> {
|
|
179
|
-
if (!this.
|
|
180
|
+
if (!this.isRegistered_) {
|
|
180
181
|
console.warn('RecordingNotification is not registered');
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
@@ -205,7 +206,7 @@ class RecordingNotificationManager
|
|
|
205
206
|
async isActive(): Promise<boolean> {
|
|
206
207
|
// Recording notifications are only supported on Android
|
|
207
208
|
if (this.isIOS) {
|
|
208
|
-
return this.
|
|
209
|
+
return this.isShown_;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
if (!NativeAudioAPIModule) {
|
|
@@ -217,6 +218,10 @@ class RecordingNotificationManager
|
|
|
217
218
|
);
|
|
218
219
|
}
|
|
219
220
|
|
|
221
|
+
isRegistered(): boolean {
|
|
222
|
+
return this.isRegistered_;
|
|
223
|
+
}
|
|
224
|
+
|
|
220
225
|
/// Add an event listener for notification actions.
|
|
221
226
|
addEventListener<T extends RecordingNotificationEventName>(
|
|
222
227
|
eventName: T,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NativeAudioAPIModule } from '../../specs';
|
|
2
1
|
import { AudioEventEmitter, AudioEventSubscription } from '../../events';
|
|
2
|
+
import { NativeAudioAPIModule } from '../../specs';
|
|
3
3
|
import type { NotificationManager, SimpleNotificationOptions } from './types';
|
|
4
4
|
|
|
5
5
|
/// Simple notification manager for basic notifications with title and text.
|
|
@@ -13,9 +13,10 @@ class SimpleNotificationManager
|
|
|
13
13
|
never
|
|
14
14
|
>
|
|
15
15
|
{
|
|
16
|
+
private isRegistered_ = false;
|
|
17
|
+
private isShown_ = false;
|
|
18
|
+
|
|
16
19
|
private notificationKey = 'simple';
|
|
17
|
-
private isRegistered = false;
|
|
18
|
-
private isShown = false;
|
|
19
20
|
private audioEventEmitter: AudioEventEmitter;
|
|
20
21
|
|
|
21
22
|
constructor() {
|
|
@@ -24,7 +25,7 @@ class SimpleNotificationManager
|
|
|
24
25
|
|
|
25
26
|
/// Register the simple notification (must be called before showing).
|
|
26
27
|
async register(): Promise<void> {
|
|
27
|
-
if (this.
|
|
28
|
+
if (this.isRegistered_) {
|
|
28
29
|
console.warn('SimpleNotification is already registered');
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
@@ -42,12 +43,12 @@ class SimpleNotificationManager
|
|
|
42
43
|
throw new Error(result.error);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
this.
|
|
46
|
+
this.isRegistered_ = true;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/// Show the notification with initial options.
|
|
49
50
|
async show(options: SimpleNotificationOptions): Promise<void> {
|
|
50
|
-
if (!this.
|
|
51
|
+
if (!this.isRegistered_) {
|
|
51
52
|
throw new Error(
|
|
52
53
|
'SimpleNotification must be registered before showing. Call register() first.'
|
|
53
54
|
);
|
|
@@ -66,12 +67,12 @@ class SimpleNotificationManager
|
|
|
66
67
|
throw new Error(result.error);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
this.
|
|
70
|
+
this.isShown_ = true;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/// Update the notification with new options.
|
|
73
74
|
async update(options: SimpleNotificationOptions): Promise<void> {
|
|
74
|
-
if (!this.
|
|
75
|
+
if (!this.isShown_) {
|
|
75
76
|
console.warn('SimpleNotification is not shown. Call show() first.');
|
|
76
77
|
return;
|
|
77
78
|
}
|
|
@@ -92,7 +93,7 @@ class SimpleNotificationManager
|
|
|
92
93
|
|
|
93
94
|
/// Hide the notification (can be shown again later).
|
|
94
95
|
async hide(): Promise<void> {
|
|
95
|
-
if (!this.
|
|
96
|
+
if (!this.isShown_) {
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -108,16 +109,16 @@ class SimpleNotificationManager
|
|
|
108
109
|
throw new Error(result.error);
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
this.
|
|
112
|
+
this.isShown_ = false;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
/// Unregister the notification (must register again to use).
|
|
115
116
|
async unregister(): Promise<void> {
|
|
116
|
-
if (!this.
|
|
117
|
+
if (!this.isRegistered_) {
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
if (this.
|
|
121
|
+
if (this.isShown_) {
|
|
121
122
|
await this.hide();
|
|
122
123
|
}
|
|
123
124
|
|
|
@@ -133,7 +134,7 @@ class SimpleNotificationManager
|
|
|
133
134
|
throw new Error(result.error);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
this.
|
|
137
|
+
this.isRegistered_ = false;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/// Check if the notification is currently active.
|
|
@@ -147,6 +148,10 @@ class SimpleNotificationManager
|
|
|
147
148
|
);
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
isRegistered(): boolean {
|
|
152
|
+
return this.isRegistered_;
|
|
153
|
+
}
|
|
154
|
+
|
|
150
155
|
/// Add an event listener (SimpleNotification doesn't emit events).
|
|
151
156
|
addEventListener<T extends never>(
|
|
152
157
|
_eventName: T,
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import type { AudioEventSubscription } from '../../events';
|
|
6
6
|
import type {
|
|
7
|
+
NotificationEvents,
|
|
7
8
|
NotificationManager,
|
|
8
|
-
PlaybackNotificationInfo,
|
|
9
9
|
PlaybackControlName,
|
|
10
10
|
PlaybackNotificationEventName,
|
|
11
|
-
|
|
11
|
+
PlaybackNotificationInfo,
|
|
12
12
|
} from '../../system';
|
|
13
13
|
|
|
14
14
|
/// Mock Manager for playback notifications. Does nothing.
|
|
@@ -20,8 +20,8 @@ class PlaybackNotificationManager
|
|
|
20
20
|
PlaybackNotificationEventName
|
|
21
21
|
>
|
|
22
22
|
{
|
|
23
|
-
private
|
|
24
|
-
private
|
|
23
|
+
private isRegistered_ = false;
|
|
24
|
+
private isShown_ = false;
|
|
25
25
|
|
|
26
26
|
constructor() {}
|
|
27
27
|
|
|
@@ -41,7 +41,11 @@ class PlaybackNotificationManager
|
|
|
41
41
|
): Promise<void> {}
|
|
42
42
|
|
|
43
43
|
async isActive(): Promise<boolean> {
|
|
44
|
-
return this.
|
|
44
|
+
return this.isShown_;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
isRegistered(): boolean {
|
|
48
|
+
return this.isRegistered_;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
addEventListener<T extends PlaybackNotificationEventName>(
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import type { AudioEventSubscription } from '../../events';
|
|
6
6
|
import type {
|
|
7
|
+
NotificationEvents,
|
|
7
8
|
NotificationManager,
|
|
8
|
-
RecordingNotificationInfo,
|
|
9
9
|
RecordingControlName,
|
|
10
10
|
RecordingNotificationEventName,
|
|
11
|
-
|
|
11
|
+
RecordingNotificationInfo,
|
|
12
12
|
} from '../../system';
|
|
13
13
|
|
|
14
14
|
/// Mock Manager for recording notifications. Does nothing.
|
|
@@ -20,8 +20,8 @@ class RecordingNotificationManager
|
|
|
20
20
|
RecordingNotificationEventName
|
|
21
21
|
>
|
|
22
22
|
{
|
|
23
|
-
private
|
|
24
|
-
private
|
|
23
|
+
private isRegistered_ = false;
|
|
24
|
+
private isShown_ = false;
|
|
25
25
|
|
|
26
26
|
constructor() {}
|
|
27
27
|
|
|
@@ -41,7 +41,11 @@ class RecordingNotificationManager
|
|
|
41
41
|
): Promise<void> {}
|
|
42
42
|
|
|
43
43
|
async isActive(): Promise<boolean> {
|
|
44
|
-
return this.
|
|
44
|
+
return this.isShown_;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
isRegistered(): boolean {
|
|
48
|
+
return this.isRegistered_;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
addEventListener<T extends RecordingNotificationEventName>(
|