react-native-audio-api 0.11.0-nightly-141c86f-20251118 → 0.11.0-nightly-4e6f25c-20251119
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/cpp/audioapi/android/AudioAPIModule.cpp +10 -16
- package/android/src/main/cpp/audioapi/android/OnLoad.cpp +1 -2
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +4 -4
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +11 -20
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +24 -46
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +48 -78
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.cpp +20 -21
- package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.cpp +3 -4
- package/common/cpp/audioapi/HostObjects/AudioParamHostObject.cpp +6 -8
- package/common/cpp/audioapi/HostObjects/AudioParamHostObject.h +2 -2
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +42 -78
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +1 -1
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +14 -18
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.h +3 -3
- package/common/cpp/audioapi/HostObjects/WorkletNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/WorkletProcessingNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.cpp +10 -18
- package/common/cpp/audioapi/HostObjects/destinations/AudioDestinationNodeHostObject.h +2 -3
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +16 -28
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +4 -6
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.cpp +2 -2
- package/common/cpp/audioapi/HostObjects/effects/PeriodicWaveHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.cpp +2 -2
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.cpp +6 -12
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.h +7 -7
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +8 -10
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +1 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +13 -27
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.h +11 -12
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.cpp +15 -22
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.h +5 -7
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.cpp +7 -12
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.h +8 -9
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +16 -30
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.h +2 -4
- package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +6 -10
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.cpp +2 -2
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.cpp +6 -8
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/sources/RecorderAdapterNodeHostObject.h +4 -5
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +2 -2
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +5 -6
- package/common/cpp/audioapi/HostObjects/sources/WorkletSourceNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/utils/AudioDecoderHostObject.cpp +39 -60
- package/common/cpp/audioapi/HostObjects/utils/AudioStretcherHostObject.cpp +4 -8
- package/common/cpp/audioapi/core/AudioContext.cpp +4 -4
- package/common/cpp/audioapi/core/AudioContext.h +5 -2
- package/common/cpp/audioapi/core/AudioNode.cpp +13 -19
- package/common/cpp/audioapi/core/AudioNode.h +14 -7
- package/common/cpp/audioapi/core/AudioParam.cpp +66 -98
- package/common/cpp/audioapi/core/AudioParam.h +20 -12
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +22 -34
- package/common/cpp/audioapi/core/BaseAudioContext.h +19 -15
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +12 -17
- package/common/cpp/audioapi/core/OfflineAudioContext.h +10 -5
- package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +13 -21
- package/common/cpp/audioapi/core/analysis/AnalyserNode.h +8 -6
- package/common/cpp/audioapi/core/destinations/AudioDestinationNode.cpp +1 -0
- package/common/cpp/audioapi/core/destinations/AudioDestinationNode.h +5 -3
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +17 -36
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +2 -9
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +18 -28
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +19 -10
- package/common/cpp/audioapi/core/effects/GainNode.cpp +1 -0
- package/common/cpp/audioapi/core/effects/GainNode.h +3 -1
- package/common/cpp/audioapi/core/effects/PeriodicWave.cpp +22 -35
- package/common/cpp/audioapi/core/effects/PeriodicWave.h +4 -9
- package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +4 -5
- package/common/cpp/audioapi/core/effects/StereoPannerNode.h +4 -2
- package/common/cpp/audioapi/core/effects/WorkletNode.cpp +11 -13
- package/common/cpp/audioapi/core/effects/WorkletNode.h +15 -12
- package/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp +4 -4
- package/common/cpp/audioapi/core/effects/WorkletProcessingNode.h +15 -14
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +9 -8
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +4 -5
- package/common/cpp/audioapi/core/sources/AudioBuffer.cpp +4 -6
- package/common/cpp/audioapi/core/sources/AudioBuffer.h +4 -7
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +31 -53
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +35 -33
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +19 -20
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +38 -36
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +25 -40
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +3 -1
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +9 -9
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +3 -3
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +3 -4
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +3 -1
- package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +12 -23
- package/common/cpp/audioapi/core/sources/OscillatorNode.h +6 -4
- package/common/cpp/audioapi/core/sources/RecorderAdapterNode.cpp +3 -4
- package/common/cpp/audioapi/core/sources/RecorderAdapterNode.h +18 -16
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +7 -4
- package/common/cpp/audioapi/core/sources/StreamerNode.h +38 -30
- package/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp +5 -7
- package/common/cpp/audioapi/core/sources/WorkletSourceNode.h +15 -13
- package/common/cpp/audioapi/core/types/AudioFormat.h +1 -11
- package/common/cpp/audioapi/core/utils/AudioDecoder.h +15 -6
- package/common/cpp/audioapi/core/utils/AudioNodeDestructor.cpp +5 -6
- package/common/cpp/audioapi/core/utils/AudioNodeDestructor.h +7 -10
- package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +13 -22
- package/common/cpp/audioapi/core/utils/AudioNodeManager.h +8 -11
- package/common/cpp/audioapi/core/utils/AudioParamEventQueue.cpp +3 -3
- package/common/cpp/audioapi/core/utils/AudioParamEventQueue.h +5 -5
- package/common/cpp/audioapi/core/utils/AudioStretcher.cpp +6 -6
- package/common/cpp/audioapi/core/utils/Constants.h +5 -3
- package/common/cpp/audioapi/core/utils/ParamChangeEvent.cpp +1 -0
- package/common/cpp/audioapi/core/utils/ParamChangeEvent.h +9 -9
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +29 -34
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +14 -16
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +23 -19
- package/common/cpp/audioapi/dsp/AudioUtils.cpp +3 -9
- package/common/cpp/audioapi/dsp/AudioUtils.h +1 -1
- package/common/cpp/audioapi/dsp/Convolver.cpp +13 -25
- package/common/cpp/audioapi/dsp/Convolver.h +26 -24
- package/common/cpp/audioapi/dsp/FFT.cpp +1 -1
- package/common/cpp/audioapi/dsp/FFT.h +5 -13
- package/common/cpp/audioapi/dsp/VectorMath.cpp +9 -43
- package/common/cpp/audioapi/dsp/VectorMath.h +35 -8
- package/common/cpp/audioapi/dsp/Windows.cpp +4 -9
- package/common/cpp/audioapi/dsp/Windows.h +24 -23
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.cpp +12 -17
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +44 -39
- package/common/cpp/audioapi/events/IAudioEventHandlerRegistry.h +15 -7
- package/common/cpp/audioapi/jsi/AudioArrayBuffer.h +4 -5
- package/common/cpp/audioapi/jsi/JsiHostObject.cpp +11 -13
- package/common/cpp/audioapi/jsi/JsiHostObject.h +26 -33
- package/common/cpp/audioapi/jsi/JsiPromise.cpp +11 -21
- package/common/cpp/audioapi/jsi/JsiPromise.h +55 -46
- package/common/cpp/audioapi/jsi/RuntimeLifecycleMonitor.cpp +7 -10
- package/common/cpp/audioapi/jsi/RuntimeLifecycleMonitor.h +1 -3
- package/common/cpp/audioapi/utils/AudioArray.cpp +3 -8
- package/common/cpp/audioapi/utils/AudioArray.h +3 -11
- package/common/cpp/audioapi/utils/AudioBus.cpp +51 -149
- package/common/cpp/audioapi/utils/AudioBus.h +15 -15
- package/common/cpp/audioapi/utils/CircularAudioArray.cpp +6 -18
- package/common/cpp/audioapi/utils/CircularOverflowableAudioArray.cpp +6 -10
- package/common/cpp/audioapi/utils/CircularOverflowableAudioArray.h +2 -2
- package/common/cpp/test/src/AudioParamTest.cpp +3 -2
- package/common/cpp/test/src/AudioScheduledSourceTest.cpp +14 -35
- package/common/cpp/test/src/ConstantSourceTest.cpp +4 -6
- package/common/cpp/test/src/GainTest.cpp +3 -4
- package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +19 -11
- package/common/cpp/test/src/OscillatorTest.cpp +1 -0
- package/common/cpp/test/src/StereoPannerTest.cpp +5 -8
- package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +10 -27
- package/common/cpp/test/src/biquad/BiquadFilterChromium.h +7 -6
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +16 -28
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +13 -6
- package/ios/audioapi/ios/AudioAPIModule.h +4 -6
- package/ios/audioapi/ios/AudioAPIModule.mm +31 -46
- package/ios/audioapi/ios/core/IOSAudioPlayer.mm +24 -33
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +1 -2
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +4 -6
- package/ios/audioapi/ios/core/NativeAudioPlayer.m +3 -5
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +1 -2
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +21 -33
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +17 -37
- package/ios/audioapi/ios/system/AudioEngine.h +2 -4
- package/ios/audioapi/ios/system/AudioEngine.mm +7 -19
- package/ios/audioapi/ios/system/AudioSessionManager.h +2 -4
- package/ios/audioapi/ios/system/AudioSessionManager.mm +17 -32
- package/ios/audioapi/ios/system/LockScreenManager.mm +73 -105
- package/ios/audioapi/ios/system/NotificationManager.mm +43 -68
- package/package.json +2 -2
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
if (self.playingInfoCenter.nowPlayingInfo == nil) {
|
|
49
49
|
lockScreenInfoDict = [NSMutableDictionary dictionary];
|
|
50
50
|
} else {
|
|
51
|
-
lockScreenInfoDict =
|
|
52
|
-
initWithDictionary:self.playingInfoCenter.nowPlayingInfo];
|
|
51
|
+
lockScreenInfoDict =
|
|
52
|
+
[[NSMutableDictionary alloc] initWithDictionary:self.playingInfoCenter.nowPlayingInfo];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
for (NSString *key in LOCK_SCREEN_INFO) {
|
|
@@ -116,85 +116,70 @@
|
|
|
116
116
|
self.artworkUrl = artworkUrl;
|
|
117
117
|
|
|
118
118
|
// Custom handling of artwork in another thread, will be loaded async
|
|
119
|
-
dispatch_async(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
NSMutableDictionary *mediaDict = (center.nowPlayingInfo != nil)
|
|
172
|
-
? [[NSMutableDictionary alloc]
|
|
173
|
-
initWithDictionary:center.nowPlayingInfo]
|
|
174
|
-
: [NSMutableDictionary dictionary];
|
|
175
|
-
[mediaDict setValue:artwork forKey:MPMediaItemPropertyArtwork];
|
|
176
|
-
center.nowPlayingInfo = mediaDict;
|
|
177
|
-
});
|
|
178
|
-
});
|
|
119
|
+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
|
|
120
|
+
UIImage *image = nil;
|
|
121
|
+
|
|
122
|
+
// check whether artwork path is present
|
|
123
|
+
if ([artworkUrl isEqual:@""]) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// artwork is url download from the interwebs
|
|
128
|
+
if ([artworkUrl hasPrefix:@"http://"] || [artworkUrl hasPrefix:@"https://"]) {
|
|
129
|
+
NSURL *imageURL = [NSURL URLWithString:artworkUrl];
|
|
130
|
+
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
|
|
131
|
+
image = [UIImage imageWithData:imageData];
|
|
132
|
+
} else {
|
|
133
|
+
NSString *localArtworkUrl = [artworkUrl stringByReplacingOccurrencesOfString:@"file://"
|
|
134
|
+
withString:@""];
|
|
135
|
+
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:localArtworkUrl];
|
|
136
|
+
if (fileExists) {
|
|
137
|
+
image = [UIImage imageNamed:localArtworkUrl];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Check if image was available otherwise don't do anything
|
|
142
|
+
if (image == nil) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// check whether image is loaded
|
|
147
|
+
CGImageRef cgref = [image CGImage];
|
|
148
|
+
CIImage *cim = [image CIImage];
|
|
149
|
+
|
|
150
|
+
if (cim == nil && cgref == NULL) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
155
|
+
// Check if URL wasn't changed in the meantime
|
|
156
|
+
if (![artworkUrl isEqual:self.artworkUrl]) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
|
|
161
|
+
MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc]
|
|
162
|
+
initWithBoundsSize:image.size
|
|
163
|
+
requestHandler:^UIImage *_Nonnull(CGSize size) { return image; }];
|
|
164
|
+
NSMutableDictionary *mediaDict = (center.nowPlayingInfo != nil)
|
|
165
|
+
? [[NSMutableDictionary alloc] initWithDictionary:center.nowPlayingInfo]
|
|
166
|
+
: [NSMutableDictionary dictionary];
|
|
167
|
+
[mediaDict setValue:artwork forKey:MPMediaItemPropertyArtwork];
|
|
168
|
+
center.nowPlayingInfo = mediaDict;
|
|
169
|
+
});
|
|
170
|
+
});
|
|
179
171
|
}
|
|
180
172
|
|
|
181
173
|
- (void)enableRemoteCommand:(NSString *)name enabled:(BOOL)enabled
|
|
182
174
|
{
|
|
183
|
-
MPRemoteCommandCenter *remoteCenter =
|
|
184
|
-
[MPRemoteCommandCenter sharedCommandCenter];
|
|
175
|
+
MPRemoteCommandCenter *remoteCenter = [MPRemoteCommandCenter sharedCommandCenter];
|
|
185
176
|
|
|
186
177
|
if ([name isEqual:@"remotePlay"]) {
|
|
187
|
-
[self enableCommand:remoteCenter.playCommand
|
|
188
|
-
withSelector:@selector(onPlay:)
|
|
189
|
-
enabled:enabled];
|
|
178
|
+
[self enableCommand:remoteCenter.playCommand withSelector:@selector(onPlay:) enabled:enabled];
|
|
190
179
|
} else if ([name isEqual:@"remotePause"]) {
|
|
191
|
-
[self enableCommand:remoteCenter.pauseCommand
|
|
192
|
-
withSelector:@selector(onPause:)
|
|
193
|
-
enabled:enabled];
|
|
180
|
+
[self enableCommand:remoteCenter.pauseCommand withSelector:@selector(onPause:) enabled:enabled];
|
|
194
181
|
} else if ([name isEqual:@"remoteStop"]) {
|
|
195
|
-
[self enableCommand:remoteCenter.stopCommand
|
|
196
|
-
withSelector:@selector(onStop:)
|
|
197
|
-
enabled:enabled];
|
|
182
|
+
[self enableCommand:remoteCenter.stopCommand withSelector:@selector(onStop:) enabled:enabled];
|
|
198
183
|
} else if ([name isEqual:@"remoteTogglePlayPause"]) {
|
|
199
184
|
[self enableCommand:remoteCenter.togglePlayPauseCommand
|
|
200
185
|
withSelector:@selector(onTogglePlayPause:)
|
|
@@ -236,9 +221,7 @@
|
|
|
236
221
|
}
|
|
237
222
|
}
|
|
238
223
|
|
|
239
|
-
- (void)enableCommand:(MPRemoteCommand *)command
|
|
240
|
-
withSelector:(SEL)selector
|
|
241
|
-
enabled:(BOOL)enabled
|
|
224
|
+
- (void)enableCommand:(MPRemoteCommand *)command withSelector:(SEL)selector enabled:(BOOL)enabled
|
|
242
225
|
{
|
|
243
226
|
[command removeTarget:self action:selector];
|
|
244
227
|
if (enabled) {
|
|
@@ -267,79 +250,64 @@
|
|
|
267
250
|
|
|
268
251
|
- (MPRemoteCommandHandlerStatus)onTogglePlayPause:(MPRemoteCommandEvent *)event
|
|
269
252
|
{
|
|
270
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteTogglePlayPause"
|
|
271
|
-
eventBody:nil];
|
|
253
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteTogglePlayPause" eventBody:nil];
|
|
272
254
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
273
255
|
}
|
|
274
256
|
|
|
275
|
-
- (MPRemoteCommandHandlerStatus)onChangePlaybackRate:
|
|
276
|
-
(MPChangePlaybackRateCommandEvent *)event
|
|
257
|
+
- (MPRemoteCommandHandlerStatus)onChangePlaybackRate:(MPChangePlaybackRateCommandEvent *)event
|
|
277
258
|
{
|
|
278
|
-
NSDictionary *body =
|
|
279
|
-
@{@"value" : [NSNumber numberWithDouble:event.playbackRate]};
|
|
259
|
+
NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.playbackRate]};
|
|
280
260
|
|
|
281
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteChangePlaybackRate"
|
|
282
|
-
eventBody:body];
|
|
261
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteChangePlaybackRate" eventBody:body];
|
|
283
262
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
284
263
|
}
|
|
285
264
|
|
|
286
265
|
- (MPRemoteCommandHandlerStatus)onNextTrack:(MPRemoteCommandEvent *)event
|
|
287
266
|
{
|
|
288
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteNextTrack"
|
|
289
|
-
eventBody:nil];
|
|
267
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteNextTrack" eventBody:nil];
|
|
290
268
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
291
269
|
}
|
|
292
270
|
|
|
293
271
|
- (MPRemoteCommandHandlerStatus)onPreviousTrack:(MPRemoteCommandEvent *)event
|
|
294
272
|
{
|
|
295
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remotePreviousTrack"
|
|
296
|
-
eventBody:nil];
|
|
273
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remotePreviousTrack" eventBody:nil];
|
|
297
274
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
298
275
|
}
|
|
299
276
|
|
|
300
277
|
- (MPRemoteCommandHandlerStatus)onSeekForward:(MPRemoteCommandEvent *)event
|
|
301
278
|
{
|
|
302
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekForward"
|
|
303
|
-
eventBody:nil];
|
|
279
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekForward" eventBody:nil];
|
|
304
280
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
305
281
|
}
|
|
306
282
|
|
|
307
283
|
- (MPRemoteCommandHandlerStatus)onSeekBackward:(MPRemoteCommandEvent *)event
|
|
308
284
|
{
|
|
309
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekBackward"
|
|
310
|
-
eventBody:nil];
|
|
285
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekBackward" eventBody:nil];
|
|
311
286
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
312
287
|
}
|
|
313
288
|
|
|
314
|
-
- (MPRemoteCommandHandlerStatus)onSkipForward:
|
|
315
|
-
(MPSkipIntervalCommandEvent *)event
|
|
289
|
+
- (MPRemoteCommandHandlerStatus)onSkipForward:(MPSkipIntervalCommandEvent *)event
|
|
316
290
|
{
|
|
317
291
|
NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.interval]};
|
|
318
292
|
|
|
319
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipForward"
|
|
320
|
-
eventBody:body];
|
|
293
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipForward" eventBody:body];
|
|
321
294
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
322
295
|
}
|
|
323
296
|
|
|
324
|
-
- (MPRemoteCommandHandlerStatus)onSkipBackward:
|
|
325
|
-
(MPSkipIntervalCommandEvent *)event
|
|
297
|
+
- (MPRemoteCommandHandlerStatus)onSkipBackward:(MPSkipIntervalCommandEvent *)event
|
|
326
298
|
{
|
|
327
299
|
NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.interval]};
|
|
328
300
|
|
|
329
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipBackward"
|
|
330
|
-
eventBody:body];
|
|
301
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipBackward" eventBody:body];
|
|
331
302
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
332
303
|
}
|
|
333
304
|
|
|
334
305
|
- (MPRemoteCommandHandlerStatus)onChangePlaybackPosition:
|
|
335
306
|
(MPChangePlaybackPositionCommandEvent *)event
|
|
336
307
|
{
|
|
337
|
-
NSDictionary *body =
|
|
338
|
-
@{@"value" : [NSNumber numberWithDouble:event.positionTime]};
|
|
308
|
+
NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.positionTime]};
|
|
339
309
|
|
|
340
|
-
[self.audioAPIModule
|
|
341
|
-
invokeHandlerWithEventName:@"remoteChangePlaybackPosition"
|
|
342
|
-
eventBody:body];
|
|
310
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteChangePlaybackPosition" eventBody:body];
|
|
343
311
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
344
312
|
}
|
|
345
313
|
|
|
@@ -37,21 +37,18 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
37
37
|
if (!enabled) {
|
|
38
38
|
[self stopPollingSecondaryAudioHint];
|
|
39
39
|
|
|
40
|
-
[self.notificationCenter
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
object:nil];
|
|
40
|
+
[self.notificationCenter removeObserver:self
|
|
41
|
+
name:AVAudioSessionSilenceSecondaryAudioHintNotification
|
|
42
|
+
object:nil];
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
[self.notificationCenter
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
object:nil];
|
|
46
|
+
[self.notificationCenter addObserver:self
|
|
47
|
+
selector:@selector(handleSecondaryAudio:)
|
|
48
|
+
name:AVAudioSessionSilenceSecondaryAudioHintNotification
|
|
49
|
+
object:nil];
|
|
52
50
|
|
|
53
|
-
dispatch_async(
|
|
54
|
-
dispatch_get_main_queue(), ^{ [self startPollingSecondaryAudioHint]; });
|
|
51
|
+
dispatch_async(dispatch_get_main_queue(), ^{ [self startPollingSecondaryAudioHint]; });
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
// WARNING: this does not work in a simulator environment, test it on a real
|
|
@@ -63,15 +60,12 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
if (enabled) {
|
|
66
|
-
[[AVAudioSession sharedInstance]
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
context:(void *)&NotificationManagerContext];
|
|
63
|
+
[[AVAudioSession sharedInstance] addObserver:self
|
|
64
|
+
forKeyPath:@"outputVolume"
|
|
65
|
+
options:NSKeyValueObservingOptionNew
|
|
66
|
+
context:(void *)&NotificationManagerContext];
|
|
71
67
|
} else {
|
|
72
|
-
[[AVAudioSession sharedInstance] removeObserver:self
|
|
73
|
-
forKeyPath:@"outputVolume"
|
|
74
|
-
context:nil];
|
|
68
|
+
[[AVAudioSession sharedInstance] removeObserver:self forKeyPath:@"outputVolume" context:nil];
|
|
75
69
|
}
|
|
76
70
|
|
|
77
71
|
self.volumeChangesObserved = enabled;
|
|
@@ -83,16 +77,14 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
83
77
|
selector:@selector(handleRouteChange:)
|
|
84
78
|
name:AVAudioSessionRouteChangeNotification
|
|
85
79
|
object:nil];
|
|
86
|
-
[self.notificationCenter
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
name:AVAudioEngineConfigurationChangeNotification
|
|
95
|
-
object:nil];
|
|
80
|
+
[self.notificationCenter addObserver:self
|
|
81
|
+
selector:@selector(handleMediaServicesReset:)
|
|
82
|
+
name:AVAudioSessionMediaServicesWereResetNotification
|
|
83
|
+
object:nil];
|
|
84
|
+
[self.notificationCenter addObserver:self
|
|
85
|
+
selector:@selector(handleEngineConfigurationChange:)
|
|
86
|
+
name:AVAudioEngineConfigurationChangeNotification
|
|
87
|
+
object:nil];
|
|
96
88
|
[self.notificationCenter addObserver:self
|
|
97
89
|
selector:@selector(handleInterruption:)
|
|
98
90
|
name:AVAudioSessionInterruptionNotification
|
|
@@ -109,11 +101,9 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
if ([keyPath isEqualToString:@"outputVolume"]) {
|
|
112
|
-
NSDictionary *body =
|
|
113
|
-
@{@"value" : [NSNumber numberWithFloat:[change[@"new"] floatValue]]};
|
|
104
|
+
NSDictionary *body = @{@"value" : [NSNumber numberWithFloat:[change[@"new"] floatValue]]};
|
|
114
105
|
if (self.volumeChangesObserved) {
|
|
115
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"volumeChange"
|
|
116
|
-
eventBody:body];
|
|
106
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"volumeChange" eventBody:body];
|
|
117
107
|
}
|
|
118
108
|
}
|
|
119
109
|
}
|
|
@@ -131,8 +121,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
131
121
|
|
|
132
122
|
if (self.audioInterruptionsObserved) {
|
|
133
123
|
NSDictionary *body = @{@"type" : @"began", @"shouldResume" : @false};
|
|
134
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
135
|
-
eventBody:body];
|
|
124
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
136
125
|
}
|
|
137
126
|
|
|
138
127
|
return;
|
|
@@ -143,8 +132,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
143
132
|
|
|
144
133
|
if (self.audioInterruptionsObserved) {
|
|
145
134
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @true};
|
|
146
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
147
|
-
eventBody:body];
|
|
135
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
148
136
|
}
|
|
149
137
|
|
|
150
138
|
return;
|
|
@@ -152,8 +140,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
152
140
|
|
|
153
141
|
if (self.audioInterruptionsObserved) {
|
|
154
142
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @false};
|
|
155
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
156
|
-
eventBody:body];
|
|
143
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
157
144
|
}
|
|
158
145
|
}
|
|
159
146
|
|
|
@@ -161,8 +148,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
161
148
|
{
|
|
162
149
|
AudioEngine *audioEngine = self.audioAPIModule.audioEngine;
|
|
163
150
|
NSInteger secondaryAudioType =
|
|
164
|
-
[notification.userInfo[AVAudioSessionSilenceSecondaryAudioHintTypeKey]
|
|
165
|
-
integerValue];
|
|
151
|
+
[notification.userInfo[AVAudioSessionSilenceSecondaryAudioHintTypeKey] integerValue];
|
|
166
152
|
|
|
167
153
|
NSLog(@"handleSecondaryAudio");
|
|
168
154
|
|
|
@@ -171,8 +157,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
171
157
|
|
|
172
158
|
if (self.audioInterruptionsObserved) {
|
|
173
159
|
NSDictionary *body = @{@"type" : @"began", @"shouldResume" : @false};
|
|
174
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
175
|
-
eventBody:body];
|
|
160
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
176
161
|
}
|
|
177
162
|
|
|
178
163
|
return;
|
|
@@ -183,8 +168,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
183
168
|
|
|
184
169
|
if (self.audioInterruptionsObserved) {
|
|
185
170
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @true};
|
|
186
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
187
|
-
eventBody:body];
|
|
171
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
188
172
|
}
|
|
189
173
|
|
|
190
174
|
return;
|
|
@@ -192,8 +176,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
192
176
|
|
|
193
177
|
if (self.audioInterruptionsObserved) {
|
|
194
178
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @false};
|
|
195
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
196
|
-
eventBody:body];
|
|
179
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
197
180
|
}
|
|
198
181
|
}
|
|
199
182
|
|
|
@@ -235,8 +218,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
235
218
|
|
|
236
219
|
NSDictionary *body = @{@"reason" : reasonStr};
|
|
237
220
|
|
|
238
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"routeChange"
|
|
239
|
-
eventBody:body];
|
|
221
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"routeChange" eventBody:body];
|
|
240
222
|
}
|
|
241
223
|
|
|
242
224
|
- (void)handleMediaServicesReset:(NSNotification *)notification
|
|
@@ -244,8 +226,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
244
226
|
NSLog(
|
|
245
227
|
@"[NotificationManager] Media services have been reset, tearing down and rebuilding everything.");
|
|
246
228
|
AudioEngine *audioEngine = self.audioAPIModule.audioEngine;
|
|
247
|
-
AudioSessionManager *audioSessionManager =
|
|
248
|
-
self.audioAPIModule.audioSessionManager;
|
|
229
|
+
AudioSessionManager *audioSessionManager = self.audioAPIModule.audioSessionManager;
|
|
249
230
|
|
|
250
231
|
[audioSessionManager reconfigureAudioSession];
|
|
251
232
|
[audioEngine restartAudioEngine];
|
|
@@ -257,8 +238,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
257
238
|
AudioSessionManager *sessionManager = self.audioAPIModule.audioSessionManager;
|
|
258
239
|
|
|
259
240
|
if (![audioEngine isSupposedToBeRunning]) {
|
|
260
|
-
NSLog(
|
|
261
|
-
@"[NotificationManager] detected engine configuration change when engine is not running");
|
|
241
|
+
NSLog(@"[NotificationManager] detected engine configuration change when engine is not running");
|
|
262
242
|
[sessionManager markSettingsAsDirty];
|
|
263
243
|
return;
|
|
264
244
|
}
|
|
@@ -277,15 +257,13 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
277
257
|
}
|
|
278
258
|
|
|
279
259
|
self.wasOtherAudioPlaying = false;
|
|
280
|
-
self.hintPollingTimer =
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
[[NSRunLoop mainRunLoop] addTimer:self.hintPollingTimer
|
|
288
|
-
forMode:NSRunLoopCommonModes];
|
|
260
|
+
self.hintPollingTimer = [NSTimer scheduledTimerWithTimeInterval:0.5
|
|
261
|
+
target:self
|
|
262
|
+
selector:@selector(checkSecondaryAudioHint)
|
|
263
|
+
userInfo:nil
|
|
264
|
+
repeats:YES];
|
|
265
|
+
|
|
266
|
+
[[NSRunLoop mainRunLoop] addTimer:self.hintPollingTimer forMode:NSRunLoopCommonModes];
|
|
289
267
|
}
|
|
290
268
|
|
|
291
269
|
- (void)stopPollingSecondaryAudioHint
|
|
@@ -296,8 +274,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
296
274
|
|
|
297
275
|
- (void)checkSecondaryAudioHint
|
|
298
276
|
{
|
|
299
|
-
BOOL shouldSilence =
|
|
300
|
-
[AVAudioSession sharedInstance].secondaryAudioShouldBeSilencedHint;
|
|
277
|
+
BOOL shouldSilence = [AVAudioSession sharedInstance].secondaryAudioShouldBeSilencedHint;
|
|
301
278
|
|
|
302
279
|
if (shouldSilence == self.wasOtherAudioPlaying) {
|
|
303
280
|
return;
|
|
@@ -311,8 +288,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
311
288
|
NSDictionary *body = @{@"type" : @"began", @"shouldResume" : @false};
|
|
312
289
|
|
|
313
290
|
if (self.audioInterruptionsObserved) {
|
|
314
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
315
|
-
eventBody:body];
|
|
291
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
316
292
|
}
|
|
317
293
|
|
|
318
294
|
return;
|
|
@@ -322,8 +298,7 @@ static NSString *NotificationManagerContext = @"NotificationManagerContext";
|
|
|
322
298
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @true};
|
|
323
299
|
|
|
324
300
|
if (self.audioInterruptionsObserved) {
|
|
325
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"interruption"
|
|
326
|
-
eventBody:body];
|
|
301
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
|
|
327
302
|
}
|
|
328
303
|
}
|
|
329
304
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.11.0-nightly-
|
|
3
|
+
"version": "0.11.0-nightly-4e6f25c-20251119",
|
|
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"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"format:android:cpp": "find android/src/ -path android/src/main/cpp/audioapi/android/libs -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
|
54
54
|
"format:android:kotlin": "ktlint -F 'android/src/main/java/**/*.kt'",
|
|
55
55
|
"format:ios": "find ios/audioapi/ios -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.mm\" | xargs clang-format -i",
|
|
56
|
-
"format:common": "find common/cpp/ -path 'common/cpp/audioapi/libs' -prune -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
|
56
|
+
"format:common": "find common/cpp/ -path 'common/cpp/audioapi/libs' -prune -o -path 'common/cpp/audioapi/external' -prune -o -type f -iname \"*.h\" -print -o -type f -iname \"*.cpp\" -print | xargs clang-format -i",
|
|
57
57
|
"build": "bob build",
|
|
58
58
|
"create:package": "./scripts/create-package.sh",
|
|
59
59
|
"prepack": "cp ../../README.md ./README.md",
|