react-native-audio-api 0.11.0-nightly-db51488-20251207 → 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.
Files changed (134) hide show
  1. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +164 -16
  2. package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioPlayer.kt +10 -8
  3. package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioRecorder.kt +10 -8
  4. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +8 -23
  5. package/android/src/main/java/com/swmansion/audioapi/system/CentralizedForegroundService.kt +127 -0
  6. package/android/src/main/java/com/swmansion/audioapi/system/ForegroundServiceManager.kt +116 -0
  7. package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +115 -107
  8. package/android/src/main/java/com/swmansion/audioapi/system/PermissionRequestListener.kt +2 -1
  9. package/android/src/main/java/com/swmansion/audioapi/system/notification/BaseNotification.kt +47 -0
  10. package/android/src/main/java/com/swmansion/audioapi/system/notification/NotificationRegistry.kt +191 -0
  11. package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotification.kt +668 -0
  12. package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotificationReceiver.kt +33 -0
  13. package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotification.kt +303 -0
  14. package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotificationReceiver.kt +43 -0
  15. package/android/src/main/java/com/swmansion/audioapi/system/notification/SimpleNotification.kt +119 -0
  16. package/ios/audioapi/ios/AudioAPIModule.h +2 -2
  17. package/ios/audioapi/ios/AudioAPIModule.mm +108 -18
  18. package/ios/audioapi/ios/system/AudioEngine.mm +2 -2
  19. package/ios/audioapi/ios/system/AudioSessionManager.mm +1 -1
  20. package/ios/audioapi/ios/system/NotificationManager.mm +1 -1
  21. package/ios/audioapi/ios/system/notification/BaseNotification.h +58 -0
  22. package/ios/audioapi/ios/system/notification/NotificationRegistry.h +70 -0
  23. package/ios/audioapi/ios/system/notification/NotificationRegistry.mm +172 -0
  24. package/ios/audioapi/ios/system/notification/PlaybackNotification.h +27 -0
  25. package/ios/audioapi/ios/system/notification/PlaybackNotification.mm +427 -0
  26. package/lib/commonjs/api.js +59 -10
  27. package/lib/commonjs/api.js.map +1 -1
  28. package/lib/commonjs/api.web.js +27 -14
  29. package/lib/commonjs/api.web.js.map +1 -1
  30. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  31. package/lib/commonjs/system/AudioManager.js +6 -9
  32. package/lib/commonjs/system/AudioManager.js.map +1 -1
  33. package/lib/commonjs/system/index.js +13 -0
  34. package/lib/commonjs/system/index.js.map +1 -1
  35. package/lib/commonjs/system/notification/PlaybackNotificationManager.js +135 -0
  36. package/lib/commonjs/system/notification/PlaybackNotificationManager.js.map +1 -0
  37. package/lib/commonjs/system/notification/RecordingNotificationManager.js +182 -0
  38. package/lib/commonjs/system/notification/RecordingNotificationManager.js.map +1 -0
  39. package/lib/commonjs/system/notification/SimpleNotificationManager.js +122 -0
  40. package/lib/commonjs/system/notification/SimpleNotificationManager.js.map +1 -0
  41. package/lib/commonjs/system/notification/index.js +45 -0
  42. package/lib/commonjs/system/notification/index.js.map +1 -0
  43. package/lib/commonjs/system/notification/types.js +6 -0
  44. package/lib/commonjs/system/notification/types.js.map +1 -0
  45. package/lib/commonjs/web-system/index.js +17 -0
  46. package/lib/commonjs/web-system/index.js.map +1 -0
  47. package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js +34 -0
  48. package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js.map +1 -0
  49. package/lib/commonjs/web-system/notification/RecordingNotificationManager.js +34 -0
  50. package/lib/commonjs/web-system/notification/RecordingNotificationManager.js.map +1 -0
  51. package/lib/commonjs/web-system/notification/index.js +21 -0
  52. package/lib/commonjs/web-system/notification/index.js.map +1 -0
  53. package/lib/module/api.js +5 -1
  54. package/lib/module/api.js.map +1 -1
  55. package/lib/module/api.web.js +3 -1
  56. package/lib/module/api.web.js.map +1 -1
  57. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  58. package/lib/module/system/AudioManager.js +6 -9
  59. package/lib/module/system/AudioManager.js.map +1 -1
  60. package/lib/module/system/index.js +1 -0
  61. package/lib/module/system/index.js.map +1 -1
  62. package/lib/module/system/notification/PlaybackNotificationManager.js +131 -0
  63. package/lib/module/system/notification/PlaybackNotificationManager.js.map +1 -0
  64. package/lib/module/system/notification/RecordingNotificationManager.js +178 -0
  65. package/lib/module/system/notification/RecordingNotificationManager.js.map +1 -0
  66. package/lib/module/system/notification/SimpleNotificationManager.js +118 -0
  67. package/lib/module/system/notification/SimpleNotificationManager.js.map +1 -0
  68. package/lib/module/system/notification/index.js +7 -0
  69. package/lib/module/system/notification/index.js.map +1 -0
  70. package/lib/module/system/notification/types.js +4 -0
  71. package/lib/module/system/notification/types.js.map +1 -0
  72. package/lib/module/web-system/index.js +4 -0
  73. package/lib/module/web-system/index.js.map +1 -0
  74. package/lib/module/web-system/notification/PlaybackNotificationManager.js +30 -0
  75. package/lib/module/web-system/notification/PlaybackNotificationManager.js.map +1 -0
  76. package/lib/module/web-system/notification/RecordingNotificationManager.js +30 -0
  77. package/lib/module/web-system/notification/RecordingNotificationManager.js.map +1 -0
  78. package/lib/module/web-system/notification/index.js +5 -0
  79. package/lib/module/web-system/notification/index.js.map +1 -0
  80. package/lib/typescript/api.d.ts +3 -1
  81. package/lib/typescript/api.d.ts.map +1 -1
  82. package/lib/typescript/api.web.d.ts +3 -1
  83. package/lib/typescript/api.web.d.ts.map +1 -1
  84. package/lib/typescript/events/types.d.ts +4 -18
  85. package/lib/typescript/events/types.d.ts.map +1 -1
  86. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +16 -5
  87. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  88. package/lib/typescript/system/AudioManager.d.ts +4 -5
  89. package/lib/typescript/system/AudioManager.d.ts.map +1 -1
  90. package/lib/typescript/system/index.d.ts +1 -0
  91. package/lib/typescript/system/index.d.ts.map +1 -1
  92. package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts +22 -0
  93. package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts.map +1 -0
  94. package/lib/typescript/system/notification/RecordingNotificationManager.d.ts +23 -0
  95. package/lib/typescript/system/notification/RecordingNotificationManager.d.ts.map +1 -0
  96. package/lib/typescript/system/notification/SimpleNotificationManager.d.ts +20 -0
  97. package/lib/typescript/system/notification/SimpleNotificationManager.d.ts.map +1 -0
  98. package/lib/typescript/system/notification/index.d.ts +5 -0
  99. package/lib/typescript/system/notification/index.d.ts.map +1 -0
  100. package/lib/typescript/system/notification/types.d.ts +65 -0
  101. package/lib/typescript/system/notification/types.d.ts.map +1 -0
  102. package/lib/typescript/system/types.d.ts +0 -16
  103. package/lib/typescript/system/types.d.ts.map +1 -1
  104. package/lib/typescript/web-system/index.d.ts +2 -0
  105. package/lib/typescript/web-system/index.d.ts.map +1 -0
  106. package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts +19 -0
  107. package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts.map +1 -0
  108. package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts +19 -0
  109. package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts.map +1 -0
  110. package/lib/typescript/web-system/notification/index.d.ts +3 -0
  111. package/lib/typescript/web-system/notification/index.d.ts.map +1 -0
  112. package/package.json +1 -1
  113. package/src/api.ts +17 -2
  114. package/src/api.web.ts +7 -2
  115. package/src/events/types.ts +4 -20
  116. package/src/specs/NativeAudioAPIModule.ts +23 -7
  117. package/src/system/AudioManager.ts +10 -23
  118. package/src/system/index.ts +1 -0
  119. package/src/system/notification/PlaybackNotificationManager.ts +193 -0
  120. package/src/system/notification/RecordingNotificationManager.ts +242 -0
  121. package/src/system/notification/SimpleNotificationManager.ts +170 -0
  122. package/src/system/notification/index.ts +4 -0
  123. package/src/system/notification/types.ts +110 -0
  124. package/src/system/types.ts +0 -18
  125. package/src/web-system/index.ts +1 -0
  126. package/src/web-system/notification/PlaybackNotificationManager.ts +60 -0
  127. package/src/web-system/notification/RecordingNotificationManager.ts +60 -0
  128. package/src/web-system/notification/index.ts +2 -0
  129. package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +0 -347
  130. package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +0 -273
  131. package/android/src/main/java/com/swmansion/audioapi/system/MediaReceiver.kt +0 -57
  132. package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionCallback.kt +0 -61
  133. package/ios/audioapi/ios/system/LockScreenManager.h +0 -23
  134. package/ios/audioapi/ios/system/LockScreenManager.mm +0 -314
@@ -0,0 +1,58 @@
1
+ #pragma once
2
+
3
+ #import <Foundation/Foundation.h>
4
+
5
+ /**
6
+ * BaseNotification protocol
7
+ *
8
+ * Interface that all notification types must implement.
9
+ */
10
+ @protocol BaseNotification <NSObject>
11
+
12
+ @required
13
+
14
+ /**
15
+ * Initialize the notification.
16
+ * @param options Initialization options (can be nil)
17
+ * @return YES if successful
18
+ */
19
+ - (BOOL)initializeWithOptions:(NSDictionary *)options;
20
+
21
+ /**
22
+ * Show the notification (sets metadata on iOS).
23
+ * @param options Notification options
24
+ * @return YES if successful
25
+ */
26
+ - (BOOL)showWithOptions:(NSDictionary *)options;
27
+
28
+ /**
29
+ * Update notification metadata.
30
+ * @param options Updated information
31
+ * @return YES if successful
32
+ */
33
+ - (BOOL)updateWithOptions:(NSDictionary *)options;
34
+
35
+ /**
36
+ * Hide the notification (clears metadata on iOS).
37
+ * @return YES if successful
38
+ */
39
+ - (BOOL)hide;
40
+
41
+ /**
42
+ * Clean up and release resources.
43
+ */
44
+ - (void)cleanup;
45
+
46
+ /**
47
+ * Check if notification is active.
48
+ * @return YES if active
49
+ */
50
+ - (BOOL)isActive;
51
+
52
+ /**
53
+ * Get notification type identifier.
54
+ * @return Type identifier (e.g., "playback", "recording")
55
+ */
56
+ - (NSString *)getNotificationType;
57
+
58
+ @end
@@ -0,0 +1,70 @@
1
+ #pragma once
2
+
3
+ #import <Foundation/Foundation.h>
4
+ #import <audioapi/ios/system/notification/BaseNotification.h>
5
+
6
+ @class AudioAPIModule;
7
+
8
+ /**
9
+ * NotificationRegistry
10
+ *
11
+ * Central manager for all notification types.
12
+ * Manages registration, lifecycle, and routing of notification implementations.
13
+ */
14
+ @interface NotificationRegistry : NSObject
15
+
16
+ @property (nonatomic, weak) AudioAPIModule *audioAPIModule;
17
+
18
+ - (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule;
19
+
20
+ /**
21
+ * Register a new notification type.
22
+ * @param type The notification type identifier (e.g., "playback", "recording")
23
+ * @param key Unique key for this notification instance
24
+ * @return YES if registration succeeded, NO otherwise
25
+ */
26
+ - (BOOL)registerNotificationType:(NSString *)type withKey:(NSString *)key;
27
+
28
+ /**
29
+ * Show a registered notification.
30
+ * @param key The notification key
31
+ * @param options Options for showing the notification
32
+ * @return YES if successful, NO otherwise
33
+ */
34
+ - (BOOL)showNotificationWithKey:(NSString *)key options:(NSDictionary *)options;
35
+
36
+ /**
37
+ * Update a shown notification.
38
+ * @param key The notification key
39
+ * @param options Updated options
40
+ * @return YES if successful, NO otherwise
41
+ */
42
+ - (BOOL)updateNotificationWithKey:(NSString *)key options:(NSDictionary *)options;
43
+
44
+ /**
45
+ * Hide a notification.
46
+ * @param key The notification key
47
+ * @return YES if successful, NO otherwise
48
+ */
49
+ - (BOOL)hideNotificationWithKey:(NSString *)key;
50
+
51
+ /**
52
+ * Unregister and clean up a notification.
53
+ * @param key The notification key
54
+ * @return YES if successful, NO otherwise
55
+ */
56
+ - (BOOL)unregisterNotificationWithKey:(NSString *)key;
57
+
58
+ /**
59
+ * Check if a notification is active.
60
+ * @param key The notification key
61
+ * @return YES if active, NO otherwise
62
+ */
63
+ - (BOOL)isNotificationActiveWithKey:(NSString *)key;
64
+
65
+ /**
66
+ * Clean up all notifications.
67
+ */
68
+ - (void)cleanup;
69
+
70
+ @end
@@ -0,0 +1,172 @@
1
+ #import <audioapi/ios/AudioAPIModule.h>
2
+ #import <audioapi/ios/system/notification/NotificationRegistry.h>
3
+ #import <audioapi/ios/system/notification/PlaybackNotification.h>
4
+
5
+ @implementation NotificationRegistry {
6
+ NSMutableDictionary<NSString *, id<BaseNotification>> *_notifications;
7
+ }
8
+
9
+ - (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule
10
+ {
11
+ if (self = [super init]) {
12
+ self.audioAPIModule = audioAPIModule;
13
+ _notifications = [[NSMutableDictionary alloc] init];
14
+
15
+ NSLog(@"[NotificationRegistry] Initialized");
16
+ }
17
+
18
+ return self;
19
+ }
20
+
21
+ - (BOOL)registerNotificationType:(NSString *)type withKey:(NSString *)key
22
+ {
23
+ if (!type || !key) {
24
+ NSLog(@"[NotificationRegistry] Invalid type or key");
25
+ return false;
26
+ }
27
+
28
+ // Check if already registered
29
+ if (_notifications[key]) {
30
+ NSLog(@"[NotificationRegistry] Notification with key '%@' already registered", key);
31
+ return false;
32
+ }
33
+
34
+ // Create the appropriate notification type
35
+ id<BaseNotification> notification = [self createNotificationForType:type];
36
+
37
+ if (!notification) {
38
+ NSLog(@"[NotificationRegistry] Unknown notification type: %@", type);
39
+ return false;
40
+ }
41
+
42
+ // Store the notification
43
+ _notifications[key] = notification;
44
+
45
+ NSLog(@"[NotificationRegistry] Registered notification type '%@' with key '%@'", type, key);
46
+ return true;
47
+ }
48
+
49
+ - (BOOL)showNotificationWithKey:(NSString *)key options:(NSDictionary *)options
50
+ {
51
+ id<BaseNotification> notification = _notifications[key];
52
+
53
+ if (!notification) {
54
+ NSLog(@"[NotificationRegistry] No notification found with key: %@", key);
55
+ return false;
56
+ }
57
+
58
+ // Initialize if first time showing
59
+ if (![notification isActive]) {
60
+ if (![notification initializeWithOptions:options]) {
61
+ NSLog(@"[NotificationRegistry] Failed to initialize notification: %@", key);
62
+ return false;
63
+ }
64
+ }
65
+
66
+ BOOL success = [notification showWithOptions:options];
67
+
68
+ if (success) {
69
+ NSLog(@"[NotificationRegistry] Showed notification: %@", key);
70
+ } else {
71
+ NSLog(@"[NotificationRegistry] Failed to show notification: %@", key);
72
+ }
73
+
74
+ return success;
75
+ }
76
+
77
+ - (BOOL)updateNotificationWithKey:(NSString *)key options:(NSDictionary *)options
78
+ {
79
+ id<BaseNotification> notification = _notifications[key];
80
+
81
+ if (!notification) {
82
+ NSLog(@"[NotificationRegistry] No notification found with key: %@", key);
83
+ return false;
84
+ }
85
+
86
+ BOOL success = [notification updateWithOptions:options];
87
+
88
+ if (success) {
89
+ NSLog(@"[NotificationRegistry] Updated notification: %@", key);
90
+ } else {
91
+ NSLog(@"[NotificationRegistry] Failed to update notification: %@", key);
92
+ }
93
+
94
+ return success;
95
+ }
96
+
97
+ - (BOOL)hideNotificationWithKey:(NSString *)key
98
+ {
99
+ id<BaseNotification> notification = _notifications[key];
100
+
101
+ if (!notification) {
102
+ NSLog(@"[NotificationRegistry] No notification found with key: %@", key);
103
+ return false;
104
+ }
105
+
106
+ BOOL success = [notification hide];
107
+
108
+ if (success) {
109
+ NSLog(@"[NotificationRegistry] Hid notification: %@", key);
110
+ } else {
111
+ NSLog(@"[NotificationRegistry] Failed to hide notification: %@", key);
112
+ }
113
+
114
+ return success;
115
+ }
116
+
117
+ - (BOOL)unregisterNotificationWithKey:(NSString *)key
118
+ {
119
+ id<BaseNotification> notification = _notifications[key];
120
+
121
+ if (!notification) {
122
+ NSLog(@"[NotificationRegistry] No notification found with key: %@", key);
123
+ return false;
124
+ }
125
+
126
+ // Clean up and remove
127
+ [notification cleanup];
128
+ [_notifications removeObjectForKey:key];
129
+
130
+ NSLog(@"[NotificationRegistry] Unregistered notification: %@", key);
131
+ return true;
132
+ }
133
+
134
+ - (BOOL)isNotificationActiveWithKey:(NSString *)key
135
+ {
136
+ id<BaseNotification> notification = _notifications[key];
137
+
138
+ if (!notification) {
139
+ return false;
140
+ }
141
+
142
+ return [notification isActive];
143
+ }
144
+
145
+ - (void)cleanup
146
+ {
147
+ NSLog(@"[NotificationRegistry] Cleaning up all notifications");
148
+
149
+ // Clean up all notifications
150
+ for (id<BaseNotification> notification in [_notifications allValues]) {
151
+ [notification cleanup];
152
+ }
153
+
154
+ [_notifications removeAllObjects];
155
+ }
156
+
157
+ #pragma mark - Private Methods
158
+
159
+ - (id<BaseNotification>)createNotificationForType:(NSString *)type
160
+ {
161
+ if ([type isEqualToString:@"playback"]) {
162
+ return [[PlaybackNotification alloc] initWithAudioAPIModule:self.audioAPIModule];
163
+ }
164
+ // Future: Add more notification types here
165
+ // else if ([type isEqualToString:@"recording"]) {
166
+ // return [[RecordingNotification alloc] initWithAudioAPIModule:self.audioAPIModule];
167
+ // }
168
+
169
+ return nil;
170
+ }
171
+
172
+ @end
@@ -0,0 +1,27 @@
1
+ #pragma once
2
+
3
+ #import <Foundation/Foundation.h>
4
+ #import <MediaPlayer/MediaPlayer.h>
5
+ #import <audioapi/ios/system/notification/BaseNotification.h>
6
+
7
+ @class AudioAPIModule;
8
+
9
+ /**
10
+ * PlaybackNotification
11
+ *
12
+ * iOS playback notification using MPNowPlayingInfoCenter and MPRemoteCommandCenter.
13
+ * Provides lock screen controls, Control Center integration, and Now Playing display.
14
+ *
15
+ * Note: On iOS, this only manages metadata. Notification visibility is controlled
16
+ * by the AudioContext state (active audio session shows controls).
17
+ */
18
+ @interface PlaybackNotification : NSObject <BaseNotification>
19
+
20
+ @property (nonatomic, weak) AudioAPIModule *audioAPIModule;
21
+ @property (nonatomic, weak) MPNowPlayingInfoCenter *playingInfoCenter;
22
+ @property (nonatomic, copy) NSString *artworkUrl;
23
+ @property (nonatomic, assign) BOOL isActive;
24
+
25
+ - (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule;
26
+
27
+ @end