Skip to content

Commit 90d150c

Browse files
committed
refactor: jsdocs, docs, removed some unused code
1 parent 4061844 commit 90d150c

File tree

12 files changed

+124
-100
lines changed

12 files changed

+124
-100
lines changed

apps/common-app/src/demos/Record/Record.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const Record: FC = () => {
4040
);
4141

4242
return () => {
43-
RecordingNotificationManager.removeEventListener(pauseListener);
44-
RecordingNotificationManager.removeEventListener(resumeListener);
43+
pauseListener.remove();
44+
resumeListener.remove();
4545
RecordingNotificationManager.hide();
4646
};
4747
}, []);

packages/audiodocs/docs/other/ffmpeg-info.mdx

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
sidebar_position: 5
33
---
44

5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
58
# FFmpeg additional information
69

710
We use [`ffmpeg`](https://github.com/FFmpeg/FFmpeg) for few components:
@@ -13,27 +16,28 @@ We use [`ffmpeg`](https://github.com/FFmpeg/FFmpeg) for few components:
1316
The ffmpeg usage is enabled by default, however if you would like not to use it, f.e. there are some name clashes with other ffmpeg
1417
binaries in your project, you can easily disable it. Just add one flag in corresponding file.
1518

16-
## Expo projects
17-
18-
Add entry in [expo plugin](/docs/fundamentals/getting-started#step-2-add-audio-api-expo-plugin-optional). If not provided, default
19-
value is `false`.
20-
21-
```
22-
"disableFFmpeg": true
23-
```
24-
25-
## Non expo projects
26-
27-
### Android
28-
29-
gradle.properties
30-
```
31-
disableAudioapiFFmpeg=true
32-
```
33-
34-
### iOS
35-
36-
Podfile
37-
```
38-
ENV['DISABLE_AUDIOAPI_FFMPEG'] = '1'
39-
```
19+
:::info
20+
FFmpeg is enabled by default
21+
:::
22+
23+
<Tabs queryString="platform">
24+
<TabItem value="expo" label="Expo" default>
25+
Add entry in [expo plugin](/docs/fundamentals/getting-started#step-2-add-audio-api-expo-plugin-optional).
26+
27+
```
28+
"disableFFmpeg": true
29+
```
30+
</TabItem>
31+
<TabItem value="iOS" label="iOS">
32+
Podfile
33+
```
34+
ENV['DISABLE_AUDIOAPI_FFMPEG'] = '1'
35+
```
36+
</TabItem>
37+
<TabItem value="android" label="Android">
38+
gradle.properties
39+
```
40+
disableAudioapiFFmpeg=true
41+
```
42+
</TabItem>
43+
</Tabs>

packages/audiodocs/docs/system/recording-notification-manager.mdx

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Shows the recording notification with the parameters.
4949
#### Returns `Promise<void>`.
5050

5151
:::info
52-
For more details about what exactly each options mean, go to [android developer page](https://developer.android.com/develop/ui/views/notifications#Templates).
52+
For more details, go to [android developer page](https://developer.android.com/develop/ui/views/notifications#Templates).
5353
Resource name is a path to resource plased in res/drawable folder. It has to be either .png file or .xml file, name is indicated without file extenstion. (photo.png -> photo).
5454
:::
5555

@@ -76,22 +76,6 @@ Hides the recording notification.
7676
| :--------: | :---------- |
7777
| `NotSupportedError` | NativeAudioAPIModule is not available |
7878

79-
### `update`
80-
81-
Updates the recording notification with the new state.
82-
83-
| Parameter |Type| Description|
84-
| :-------: | :--: | :----|
85-
| `info` | [`RecordingNotificationInfo`](recording-notification-manager#recordingnotificationinfo) | Metadata to update |
86-
87-
#### Returns `Promise<void>`.
88-
89-
#### Errors
90-
91-
| Error type | Description|
92-
| :--------: | :---------- |
93-
| `NotSupportedError` | NativeAudioAPIModule is not available |
94-
9579
### `isActive`
9680

9781
Checks if the notification is displayed.
@@ -109,14 +93,6 @@ Add an event listener for notification actions.
10993

11094
#### Returns [`AudioEventSubscription`](/docs/system/audio-manager#audioeventsubscription).
11195

112-
### `removeEventListener`
113-
114-
Remove an event listener.
115-
116-
| Parameter | Type | Description |
117-
| :------------: | :---------------------------------------------------------------------------: | :------------------------- |
118-
| `subscription` | [`AudioEventSubscription`](/docs/system/audio-manager#audioeventsubscription) | The subscription to remove |
119-
12096
## Remarks
12197

12298
### `RecordingNotificationInfo`

packages/react-native-audio-api/src/api.web.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export {
3737
PermissionStatus,
3838
} from './system/types';
3939

40-
export { PlaybackNotificationManager, AudioManager } from './web-system';
40+
export {
41+
PlaybackNotificationManager,
42+
RecordingNotificationManager,
43+
AudioManager,
44+
} from './web-system';
4145

4246
export * from './system/notification/types';
4347

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class AudioApiError extends Error {
2+
constructor(message: string) {
3+
super(message);
4+
this.name = 'AudioApiError';
5+
}
6+
}
7+
8+
export default AudioApiError;

packages/react-native-audio-api/src/errors/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export { default as InvalidAccessError } from './InvalidAccessError';
33
export { default as InvalidStateError } from './InvalidStateError';
44
export { default as RangeError } from './RangeError';
55
export { default as NotSupportedError } from './NotSupportedError';
6+
export { default as AudioApiError } from './AudioApiError';

packages/react-native-audio-api/src/system/notification/PlaybackNotificationManager.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import type {
1111
/// Manager for media playback notifications with controls and MediaSession integration.
1212
class PlaybackNotificationManager
1313
implements
14-
NotificationManager<
15-
PlaybackNotificationInfo,
16-
PlaybackNotificationInfo,
17-
PlaybackNotificationEventName
18-
>
14+
NotificationManager<PlaybackNotificationInfo, PlaybackNotificationEventName>
1915
{
2016
private notificationKey = 'playback';
2117
private audioEventEmitter: AudioEventEmitter;
@@ -102,11 +98,6 @@ class PlaybackNotificationManager
10298
): AudioEventSubscription {
10399
return this.audioEventEmitter.addAudioEventListener(eventName, callback);
104100
}
105-
106-
/** Remove an event listener. */
107-
removeEventListener(subscription: AudioEventSubscription): void {
108-
subscription.remove();
109-
}
110101
}
111102

112103
export default new PlaybackNotificationManager();

packages/react-native-audio-api/src/system/notification/RecordingNotificationManager.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,31 @@ import type {
77
RecordingNotificationInfo,
88
} from './types';
99

10-
import { NotSupportedError } from '../../errors';
10+
import { AudioApiError } from '../../errors';
1111

12-
/// Manager for media playback notifications with controls and MediaSession integration.
1312
class RecordingNotificationManager
1413
implements
1514
NotificationManager<
16-
RecordingNotificationInfo,
1715
RecordingNotificationInfo,
1816
RecordingNotificationEventName
1917
>
2018
{
21-
private notificationKey = 'react-native audio-api-recording';
19+
private notificationKey = 'react-native-audio-api-recording';
2220
private audioEventEmitter: AudioEventEmitter;
2321

2422
constructor() {
2523
this.audioEventEmitter = new AudioEventEmitter(global.AudioEventEmitter);
2624
}
2725

28-
/// Show the notification with metadata or update if already visible.
29-
/// Automatically creates the notification on first call.
26+
/**
27+
* Show the notification with metadata or update if already visible.
28+
*
29+
* @param info - The info to be displayed.
30+
* @returns Promise that resolves after creating notification.
31+
*/
3032
async show(info: RecordingNotificationInfo): Promise<void> {
3133
if (!NativeAudioAPIModule) {
32-
throw new NotSupportedError('NativeAudioAPIModule is not available');
34+
throw new AudioApiError('NativeAudioAPIModule is not available');
3335
}
3436

3537
const result = await NativeAudioAPIModule.showNotification(
@@ -43,16 +45,14 @@ class RecordingNotificationManager
4345
}
4446
}
4547

46-
/// Update the notification with new metadata or state.
47-
/// This is an alias for show() since show handles both initial display and updates.
48-
async update(info: RecordingNotificationInfo): Promise<void> {
49-
return this.show(info);
50-
}
51-
52-
/// Hide the notification.
48+
/**
49+
* Hide the notification.
50+
*
51+
* @returns Promise that resolves after hiding notification.
52+
*/
5353
async hide(): Promise<void> {
5454
if (!NativeAudioAPIModule) {
55-
throw new NotSupportedError('NativeAudioAPIModule is not available');
55+
throw new AudioApiError('NativeAudioAPIModule is not available');
5656
}
5757

5858
const result = await NativeAudioAPIModule.hideNotification(
@@ -64,7 +64,11 @@ class RecordingNotificationManager
6464
}
6565
}
6666

67-
/// Check if the notification is currently active.
67+
/**
68+
* Check if the notification is currently active.
69+
*
70+
* @returns Promise that resolves to whether notification is active.
71+
*/
6872
async isActive(): Promise<boolean> {
6973
if (!NativeAudioAPIModule) {
7074
return false;
@@ -75,18 +79,19 @@ class RecordingNotificationManager
7579
);
7680
}
7781

78-
/// Add an event listener for notification actions.
82+
/**
83+
* Add an event listener for notification actions.
84+
*
85+
* @param eventName - The event name to listen for.
86+
* @param callback - The callback to invoke on event.
87+
* @returns Promise that resolves to whether notification is active.
88+
*/
7989
addEventListener<T extends RecordingNotificationEventName>(
8090
eventName: T,
8191
callback: (event: RecordingNotificationEvent[T]) => void
8292
): AudioEventSubscription {
8393
return this.audioEventEmitter.addAudioEventListener(eventName, callback);
8494
}
85-
86-
/** Remove an event listener. */
87-
removeEventListener(subscription: AudioEventSubscription): void {
88-
subscription.remove();
89-
}
9095
}
9196

9297
export default new RecordingNotificationManager();

packages/react-native-audio-api/src/system/notification/types.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ import { EventEmptyType, EventTypeWithValue } from '../../events/types';
55
/// Provides a consistent API for managing notification lifecycle and events.
66
export interface NotificationManager<
77
TShowOptions,
8-
TUpdateOptions,
98
TEventName extends NotificationEventName,
109
> {
1110
/// Show the notification with options or update if already visible.
1211
/// Automatically creates the notification instance on first call.
1312
show(options: TShowOptions): Promise<void>;
1413

15-
/// Update the notification with new options (alias for show).
16-
update(options: TUpdateOptions): Promise<void>;
17-
1814
/// Hide the notification.
1915
hide(): Promise<void>;
2016

@@ -26,9 +22,6 @@ export interface NotificationManager<
2622
eventName: T,
2723
callback: NotificationCallback<T>
2824
): AudioEventSubscription | undefined;
29-
30-
/// Remove an event listener.
31-
removeEventListener(subscription: AudioEventSubscription): void;
3225
}
3326

3427
/// Metadata and state information for playback notifications.
@@ -77,8 +70,6 @@ export interface RecordingNotificationInfo {
7770
color?: number;
7871
}
7972

80-
export type RecordingControlName = 'pause' | 'resume';
81-
8273
export interface RecordingNotificationEvent {
8374
recordingNotificationPause: EventEmptyType;
8475
recordingNotificationResume: EventEmptyType;

packages/react-native-audio-api/src/web-system/notification/PlaybackNotificationManager.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ import type {
1414
/// Mock Manager for playback notifications. Does nothing.
1515
class PlaybackNotificationManager
1616
implements
17-
NotificationManager<
18-
PlaybackNotificationInfo,
19-
PlaybackNotificationInfo,
20-
PlaybackNotificationEventName
21-
>
17+
NotificationManager<PlaybackNotificationInfo, PlaybackNotificationEventName>
2218
{
2319
private isRegistered_ = false;
2420
private isShown_ = false;
@@ -57,8 +53,6 @@ class PlaybackNotificationManager
5753
remove: () => {},
5854
} as unknown as AudioEventSubscription;
5955
}
60-
61-
removeEventListener(subscription: AudioEventSubscription): void {}
6256
}
6357

6458
export default new PlaybackNotificationManager();

0 commit comments

Comments
 (0)