react-native-audio-api 0.11.0-nightly-010ea11-20251110 → 0.11.0-nightly-c8d92af-20251111
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/common/cpp/audioapi/AudioAPIModuleInstaller.h +1 -3
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.cpp +6 -2
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +3 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +19 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.h +3 -0
- package/common/cpp/audioapi/core/AudioContext.cpp +19 -24
- package/common/cpp/audioapi/core/AudioContext.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +16 -0
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +2 -0
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +23 -3
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +2 -0
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +16 -3
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +5 -5
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +10 -0
- package/common/cpp/audioapi/dsp/VectorMath.cpp +15 -15
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +5 -5
- package/ios/audioapi/ios/AudioAPIModule.h +6 -4
- package/ios/audioapi/ios/AudioAPIModule.mm +62 -41
- package/ios/audioapi/ios/core/IOSAudioPlayer.h +1 -1
- package/ios/audioapi/ios/core/IOSAudioPlayer.mm +33 -24
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +3 -2
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +6 -4
- package/ios/audioapi/ios/core/NativeAudioPlayer.m +18 -9
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +2 -1
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +45 -27
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +44 -19
- package/ios/audioapi/ios/system/AudioEngine.h +4 -2
- package/ios/audioapi/ios/system/AudioEngine.mm +22 -8
- package/ios/audioapi/ios/system/AudioSessionManager.h +9 -5
- package/ios/audioapi/ios/system/AudioSessionManager.mm +51 -21
- package/ios/audioapi/ios/system/LockScreenManager.mm +137 -88
- package/ios/audioapi/ios/system/NotificationManager.mm +79 -48
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/core/AudioBufferBaseSourceNode.js +3 -0
- package/lib/commonjs/core/AudioBufferBaseSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioContext.js +1 -1
- package/lib/commonjs/core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +1 -1
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/module/api.js.map +1 -1
- package/lib/module/core/AudioBufferBaseSourceNode.js +3 -0
- package/lib/module/core/AudioBufferBaseSourceNode.js.map +1 -1
- package/lib/module/core/AudioContext.js +1 -1
- package/lib/module/core/AudioContext.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +1 -1
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +1 -1
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/core/AudioBufferBaseSourceNode.d.ts +1 -0
- package/lib/typescript/core/AudioBufferBaseSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +2 -0
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +0 -1
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +0 -1
- package/src/core/AudioBufferBaseSourceNode.ts +8 -0
- package/src/core/AudioContext.ts +0 -1
- package/src/interfaces.ts +3 -0
- package/src/types.ts +0 -1
- package/src/web-core/AudioContext.tsx +1 -1
|
@@ -101,11 +101,13 @@
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
if ([option isEqualToString:@"overrideMutedMicrophoneInterruption"]) {
|
|
104
|
-
sessionOptions |=
|
|
104
|
+
sessionOptions |=
|
|
105
|
+
AVAudioSessionCategoryOptionOverrideMutedMicrophoneInterruption;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
if ([option isEqualToString:@"interruptSpokenAudioAndMixWithOthers"]) {
|
|
108
|
-
sessionOptions |=
|
|
109
|
+
sessionOptions |=
|
|
110
|
+
AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -124,9 +126,11 @@
|
|
|
124
126
|
self.sessionOptions = sessionOptions;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
if (self.allowHapticsAndSystemSoundsDuringRecording !=
|
|
129
|
+
if (self.allowHapticsAndSystemSoundsDuringRecording !=
|
|
130
|
+
allowHapticsAndSystemSoundsDuringRecording) {
|
|
128
131
|
self.hasDirtySettings = true;
|
|
129
|
-
self.allowHapticsAndSystemSoundsDuringRecording =
|
|
132
|
+
self.allowHapticsAndSystemSoundsDuringRecording =
|
|
133
|
+
allowHapticsAndSystemSoundsDuringRecording;
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
if (self.isActive) {
|
|
@@ -156,9 +160,13 @@
|
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
if (error != nil) {
|
|
159
|
-
NSLog(
|
|
163
|
+
NSLog(
|
|
164
|
+
@"[AudioSessionManager] setting session as %@ failed",
|
|
165
|
+
active ? @"ACTIVE" : @"INACTIVE");
|
|
160
166
|
} else {
|
|
161
|
-
NSLog(
|
|
167
|
+
NSLog(
|
|
168
|
+
@"[AudioSessionManager] session is %@",
|
|
169
|
+
active ? @"ACTIVE" : @"INACTIVE");
|
|
162
170
|
}
|
|
163
171
|
|
|
164
172
|
return success;
|
|
@@ -167,7 +175,8 @@
|
|
|
167
175
|
- (bool)configureAudioSession
|
|
168
176
|
{
|
|
169
177
|
if (!self.shouldManageSession) {
|
|
170
|
-
NSLog(
|
|
178
|
+
NSLog(
|
|
179
|
+
@"[AudioSessionManager] Skipping AVAudioSession configuration, shouldManageSession is false");
|
|
171
180
|
return true;
|
|
172
181
|
}
|
|
173
182
|
|
|
@@ -184,19 +193,26 @@
|
|
|
184
193
|
|
|
185
194
|
NSError *error = nil;
|
|
186
195
|
|
|
187
|
-
[self.audioSession setCategory:self.sessionCategory
|
|
196
|
+
[self.audioSession setCategory:self.sessionCategory
|
|
197
|
+
mode:self.sessionMode
|
|
198
|
+
options:self.sessionOptions
|
|
199
|
+
error:&error];
|
|
188
200
|
|
|
189
201
|
if (error != nil) {
|
|
190
|
-
NSLog(
|
|
202
|
+
NSLog(
|
|
203
|
+
@"Error while configuring audio session: %@", [error debugDescription]);
|
|
191
204
|
return false;
|
|
192
205
|
}
|
|
193
206
|
|
|
194
207
|
if (@available(iOS 13.0, *)) {
|
|
195
|
-
[self.audioSession setAllowHapticsAndSystemSoundsDuringRecording:
|
|
208
|
+
[self.audioSession setAllowHapticsAndSystemSoundsDuringRecording:
|
|
209
|
+
self.allowHapticsAndSystemSoundsDuringRecording
|
|
196
210
|
error:&error];
|
|
197
211
|
|
|
198
212
|
if (error != nil) {
|
|
199
|
-
NSLog(
|
|
213
|
+
NSLog(
|
|
214
|
+
@"Error while setting allowHapticsAndSystemSoundsDuringRecording: %@",
|
|
215
|
+
[error debugDescription]);
|
|
200
216
|
}
|
|
201
217
|
}
|
|
202
218
|
|
|
@@ -226,10 +242,13 @@
|
|
|
226
242
|
self.hasDirtySettings = false;
|
|
227
243
|
}
|
|
228
244
|
|
|
229
|
-
- (void)requestRecordingPermissions:(RCTPromiseResolveBlock)resolve
|
|
245
|
+
- (void)requestRecordingPermissions:(RCTPromiseResolveBlock)resolve
|
|
246
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
230
247
|
{
|
|
231
|
-
id value = [[NSBundle mainBundle]
|
|
232
|
-
|
|
248
|
+
id value = [[NSBundle mainBundle]
|
|
249
|
+
objectForInfoDictionaryKey:@"NSMicrophoneUsageDescription"];
|
|
250
|
+
// if there is no entry NSMicrophoneUsageDescription calling
|
|
251
|
+
// requestRecordPermission will quit an app
|
|
233
252
|
if (value == nil) {
|
|
234
253
|
reject(
|
|
235
254
|
nil,
|
|
@@ -256,7 +275,8 @@
|
|
|
256
275
|
}
|
|
257
276
|
}
|
|
258
277
|
|
|
259
|
-
- (void)checkRecordingPermissions:(RCTPromiseResolveBlock)resolve
|
|
278
|
+
- (void)checkRecordingPermissions:(RCTPromiseResolveBlock)resolve
|
|
279
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
260
280
|
{
|
|
261
281
|
if (@available(iOS 17, *)) {
|
|
262
282
|
NSInteger res = [[AVAudioApplication sharedInstance] recordPermission];
|
|
@@ -322,19 +342,29 @@
|
|
|
322
342
|
}
|
|
323
343
|
}
|
|
324
344
|
|
|
325
|
-
- (void)getDevicesInfo:(RCTPromiseResolveBlock)resolve
|
|
345
|
+
- (void)getDevicesInfo:(RCTPromiseResolveBlock)resolve
|
|
346
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
326
347
|
{
|
|
327
348
|
NSMutableDictionary *devicesInfo = [[NSMutableDictionary alloc] init];
|
|
328
349
|
|
|
329
|
-
[devicesInfo
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
[devicesInfo
|
|
350
|
+
[devicesInfo
|
|
351
|
+
setValue:[self parseDeviceList:[self.audioSession availableInputs]]
|
|
352
|
+
forKey:@"availableInputs"];
|
|
353
|
+
[devicesInfo
|
|
354
|
+
setValue:[self parseDeviceList:[[self.audioSession currentRoute] inputs]]
|
|
355
|
+
forKey:@"currentInputs"];
|
|
356
|
+
[devicesInfo
|
|
357
|
+
setValue:[self parseDeviceList:[[self.audioSession currentRoute] outputs]]
|
|
358
|
+
forKey:@"availableOutputs"];
|
|
359
|
+
[devicesInfo
|
|
360
|
+
setValue:[self parseDeviceList:[[self.audioSession currentRoute] outputs]]
|
|
361
|
+
forKey:@"currentOutputs"];
|
|
333
362
|
|
|
334
363
|
resolve(devicesInfo);
|
|
335
364
|
}
|
|
336
365
|
|
|
337
|
-
- (NSArray<NSDictionary *> *)parseDeviceList:
|
|
366
|
+
- (NSArray<NSDictionary *> *)parseDeviceList:
|
|
367
|
+
(NSArray<AVAudioSessionPortDescription *> *)devices
|
|
338
368
|
{
|
|
339
369
|
NSMutableArray<NSDictionary *> *deviceList = [[NSMutableArray alloc] init];
|
|
340
370
|
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
#import <audioapi/ios/AudioAPIModule.h>
|
|
3
3
|
#import <audioapi/ios/system/LockScreenManager.h>
|
|
4
4
|
|
|
5
|
-
#define LOCK_SCREEN_INFO
|
|
6
|
-
@{
|
|
7
|
-
@"album" : MPMediaItemPropertyAlbumTitle,
|
|
8
|
-
@"artist" : MPMediaItemPropertyArtist,
|
|
9
|
-
@"duration" : MPMediaItemPropertyPlaybackDuration,
|
|
10
|
-
@"title" : MPMediaItemPropertyTitle,
|
|
11
|
-
@"speed" : MPNowPlayingInfoPropertyPlaybackRate,
|
|
5
|
+
#define LOCK_SCREEN_INFO \
|
|
6
|
+
@{ \
|
|
7
|
+
@"album" : MPMediaItemPropertyAlbumTitle, \
|
|
8
|
+
@"artist" : MPMediaItemPropertyArtist, \
|
|
9
|
+
@"duration" : MPMediaItemPropertyPlaybackDuration, \
|
|
10
|
+
@"title" : MPMediaItemPropertyTitle, \
|
|
11
|
+
@"speed" : MPNowPlayingInfoPropertyPlaybackRate, \
|
|
12
12
|
@"elapsedTime" : MPNowPlayingInfoPropertyElapsedPlaybackTime, \
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -48,12 +48,14 @@
|
|
|
48
48
|
if (self.playingInfoCenter.nowPlayingInfo == nil) {
|
|
49
49
|
lockScreenInfoDict = [NSMutableDictionary dictionary];
|
|
50
50
|
} else {
|
|
51
|
-
lockScreenInfoDict = [[NSMutableDictionary alloc]
|
|
51
|
+
lockScreenInfoDict = [[NSMutableDictionary alloc]
|
|
52
|
+
initWithDictionary:self.playingInfoCenter.nowPlayingInfo];
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
for (NSString *key in LOCK_SCREEN_INFO) {
|
|
55
56
|
if ([info objectForKey:key] != nil) {
|
|
56
|
-
[lockScreenInfoDict setValue:[info objectForKey:key]
|
|
57
|
+
[lockScreenInfoDict setValue:[info objectForKey:key]
|
|
58
|
+
forKey:[LOCK_SCREEN_INFO objectForKey:key]];
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -114,90 +116,119 @@
|
|
|
114
116
|
self.artworkUrl = artworkUrl;
|
|
115
117
|
|
|
116
118
|
// Custom handling of artwork in another thread, will be loaded async
|
|
117
|
-
dispatch_async(
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
119
|
+
dispatch_async(
|
|
120
|
+
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
|
|
121
|
+
UIImage *image = nil;
|
|
122
|
+
|
|
123
|
+
// check whether artwork path is present
|
|
124
|
+
if ([artworkUrl isEqual:@""]) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// artwork is url download from the interwebs
|
|
129
|
+
if ([artworkUrl hasPrefix:@"http://"] ||
|
|
130
|
+
[artworkUrl hasPrefix:@"https://"]) {
|
|
131
|
+
NSURL *imageURL = [NSURL URLWithString:artworkUrl];
|
|
132
|
+
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
|
|
133
|
+
image = [UIImage imageWithData:imageData];
|
|
134
|
+
} else {
|
|
135
|
+
NSString *localArtworkUrl =
|
|
136
|
+
[artworkUrl stringByReplacingOccurrencesOfString:@"file://"
|
|
137
|
+
withString:@""];
|
|
138
|
+
BOOL fileExists =
|
|
139
|
+
[[NSFileManager defaultManager] fileExistsAtPath:localArtworkUrl];
|
|
140
|
+
if (fileExists) {
|
|
141
|
+
image = [UIImage imageNamed:localArtworkUrl];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Check if image was available otherwise don't do anything
|
|
146
|
+
if (image == nil) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// check whether image is loaded
|
|
151
|
+
CGImageRef cgref = [image CGImage];
|
|
152
|
+
CIImage *cim = [image CIImage];
|
|
153
|
+
|
|
154
|
+
if (cim == nil && cgref == NULL) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
159
|
+
// Check if URL wasn't changed in the meantime
|
|
160
|
+
if (![artworkUrl isEqual:self.artworkUrl]) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
MPNowPlayingInfoCenter *center =
|
|
165
|
+
[MPNowPlayingInfoCenter defaultCenter];
|
|
166
|
+
MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc]
|
|
167
|
+
initWithBoundsSize:image.size
|
|
168
|
+
requestHandler:^UIImage *_Nonnull(CGSize size) {
|
|
169
|
+
return image;
|
|
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
|
+
});
|
|
169
179
|
}
|
|
170
180
|
|
|
171
181
|
- (void)enableRemoteCommand:(NSString *)name enabled:(BOOL)enabled
|
|
172
182
|
{
|
|
173
|
-
MPRemoteCommandCenter *remoteCenter =
|
|
183
|
+
MPRemoteCommandCenter *remoteCenter =
|
|
184
|
+
[MPRemoteCommandCenter sharedCommandCenter];
|
|
174
185
|
|
|
175
186
|
if ([name isEqual:@"remotePlay"]) {
|
|
176
|
-
[self enableCommand:remoteCenter.playCommand
|
|
187
|
+
[self enableCommand:remoteCenter.playCommand
|
|
188
|
+
withSelector:@selector(onPlay:)
|
|
189
|
+
enabled:enabled];
|
|
177
190
|
} else if ([name isEqual:@"remotePause"]) {
|
|
178
|
-
[self enableCommand:remoteCenter.pauseCommand
|
|
191
|
+
[self enableCommand:remoteCenter.pauseCommand
|
|
192
|
+
withSelector:@selector(onPause:)
|
|
193
|
+
enabled:enabled];
|
|
179
194
|
} else if ([name isEqual:@"remoteStop"]) {
|
|
180
|
-
[self enableCommand:remoteCenter.stopCommand
|
|
195
|
+
[self enableCommand:remoteCenter.stopCommand
|
|
196
|
+
withSelector:@selector(onStop:)
|
|
197
|
+
enabled:enabled];
|
|
181
198
|
} else if ([name isEqual:@"remoteTogglePlayPause"]) {
|
|
182
|
-
[self enableCommand:remoteCenter.togglePlayPauseCommand
|
|
199
|
+
[self enableCommand:remoteCenter.togglePlayPauseCommand
|
|
200
|
+
withSelector:@selector(onTogglePlayPause:)
|
|
201
|
+
enabled:enabled];
|
|
183
202
|
} else if ([name isEqual:@"remoteChangePlaybackRate"]) {
|
|
184
203
|
[self enableCommand:remoteCenter.changePlaybackRateCommand
|
|
185
204
|
withSelector:@selector(onChangePlaybackRate:)
|
|
186
205
|
enabled:enabled];
|
|
187
206
|
} else if ([name isEqual:@"remoteNextTrack"]) {
|
|
188
|
-
[self enableCommand:remoteCenter.nextTrackCommand
|
|
207
|
+
[self enableCommand:remoteCenter.nextTrackCommand
|
|
208
|
+
withSelector:@selector(onNextTrack:)
|
|
209
|
+
enabled:enabled];
|
|
189
210
|
} else if ([name isEqual:@"remotePreviousTrack"]) {
|
|
190
|
-
[self enableCommand:remoteCenter.previousTrackCommand
|
|
211
|
+
[self enableCommand:remoteCenter.previousTrackCommand
|
|
212
|
+
withSelector:@selector(onPreviousTrack:)
|
|
213
|
+
enabled:enabled];
|
|
191
214
|
} else if ([name isEqual:@"remoteSkipForward"]) {
|
|
192
215
|
remoteCenter.skipForwardCommand.preferredIntervals = @[ @15 ];
|
|
193
|
-
[self enableCommand:remoteCenter.skipForwardCommand
|
|
216
|
+
[self enableCommand:remoteCenter.skipForwardCommand
|
|
217
|
+
withSelector:@selector(onSkipForward:)
|
|
218
|
+
enabled:enabled];
|
|
194
219
|
} else if ([name isEqual:@"remoteSkipBackward"]) {
|
|
195
220
|
remoteCenter.skipBackwardCommand.preferredIntervals = @[ @15 ];
|
|
196
|
-
[self enableCommand:remoteCenter.skipBackwardCommand
|
|
221
|
+
[self enableCommand:remoteCenter.skipBackwardCommand
|
|
222
|
+
withSelector:@selector(onSkipBackward:)
|
|
223
|
+
enabled:enabled];
|
|
197
224
|
} else if ([name isEqual:@"remoteSeekForward"]) {
|
|
198
|
-
[self enableCommand:remoteCenter.seekForwardCommand
|
|
225
|
+
[self enableCommand:remoteCenter.seekForwardCommand
|
|
226
|
+
withSelector:@selector(onSeekForward:)
|
|
227
|
+
enabled:enabled];
|
|
199
228
|
} else if ([name isEqual:@"remoteSeekBackward"]) {
|
|
200
|
-
[self enableCommand:remoteCenter.seekBackwardCommand
|
|
229
|
+
[self enableCommand:remoteCenter.seekBackwardCommand
|
|
230
|
+
withSelector:@selector(onSeekBackward:)
|
|
231
|
+
enabled:enabled];
|
|
201
232
|
} else if ([name isEqual:@"remoteChangePlaybackPosition"]) {
|
|
202
233
|
[self enableCommand:remoteCenter.changePlaybackPositionCommand
|
|
203
234
|
withSelector:@selector(onChangePlaybackPosition:)
|
|
@@ -205,7 +236,9 @@
|
|
|
205
236
|
}
|
|
206
237
|
}
|
|
207
238
|
|
|
208
|
-
- (void)enableCommand:(MPRemoteCommand *)command
|
|
239
|
+
- (void)enableCommand:(MPRemoteCommand *)command
|
|
240
|
+
withSelector:(SEL)selector
|
|
241
|
+
enabled:(BOOL)enabled
|
|
209
242
|
{
|
|
210
243
|
[command removeTarget:self action:selector];
|
|
211
244
|
if (enabled) {
|
|
@@ -234,63 +267,79 @@
|
|
|
234
267
|
|
|
235
268
|
- (MPRemoteCommandHandlerStatus)onTogglePlayPause:(MPRemoteCommandEvent *)event
|
|
236
269
|
{
|
|
237
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteTogglePlayPause"
|
|
270
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteTogglePlayPause"
|
|
271
|
+
eventBody:nil];
|
|
238
272
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
239
273
|
}
|
|
240
274
|
|
|
241
|
-
- (MPRemoteCommandHandlerStatus)onChangePlaybackRate:
|
|
275
|
+
- (MPRemoteCommandHandlerStatus)onChangePlaybackRate:
|
|
276
|
+
(MPChangePlaybackRateCommandEvent *)event
|
|
242
277
|
{
|
|
243
|
-
NSDictionary *body =
|
|
278
|
+
NSDictionary *body =
|
|
279
|
+
@{@"value" : [NSNumber numberWithDouble:event.playbackRate]};
|
|
244
280
|
|
|
245
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteChangePlaybackRate"
|
|
281
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteChangePlaybackRate"
|
|
282
|
+
eventBody:body];
|
|
246
283
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
247
284
|
}
|
|
248
285
|
|
|
249
286
|
- (MPRemoteCommandHandlerStatus)onNextTrack:(MPRemoteCommandEvent *)event
|
|
250
287
|
{
|
|
251
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteNextTrack"
|
|
288
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteNextTrack"
|
|
289
|
+
eventBody:nil];
|
|
252
290
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
253
291
|
}
|
|
254
292
|
|
|
255
293
|
- (MPRemoteCommandHandlerStatus)onPreviousTrack:(MPRemoteCommandEvent *)event
|
|
256
294
|
{
|
|
257
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remotePreviousTrack"
|
|
295
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remotePreviousTrack"
|
|
296
|
+
eventBody:nil];
|
|
258
297
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
259
298
|
}
|
|
260
299
|
|
|
261
300
|
- (MPRemoteCommandHandlerStatus)onSeekForward:(MPRemoteCommandEvent *)event
|
|
262
301
|
{
|
|
263
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekForward"
|
|
302
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekForward"
|
|
303
|
+
eventBody:nil];
|
|
264
304
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
265
305
|
}
|
|
266
306
|
|
|
267
307
|
- (MPRemoteCommandHandlerStatus)onSeekBackward:(MPRemoteCommandEvent *)event
|
|
268
308
|
{
|
|
269
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekBackward"
|
|
309
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekBackward"
|
|
310
|
+
eventBody:nil];
|
|
270
311
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
271
312
|
}
|
|
272
313
|
|
|
273
|
-
- (MPRemoteCommandHandlerStatus)onSkipForward:
|
|
314
|
+
- (MPRemoteCommandHandlerStatus)onSkipForward:
|
|
315
|
+
(MPSkipIntervalCommandEvent *)event
|
|
274
316
|
{
|
|
275
317
|
NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.interval]};
|
|
276
318
|
|
|
277
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipForward"
|
|
319
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipForward"
|
|
320
|
+
eventBody:body];
|
|
278
321
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
279
322
|
}
|
|
280
323
|
|
|
281
|
-
- (MPRemoteCommandHandlerStatus)onSkipBackward:
|
|
324
|
+
- (MPRemoteCommandHandlerStatus)onSkipBackward:
|
|
325
|
+
(MPSkipIntervalCommandEvent *)event
|
|
282
326
|
{
|
|
283
327
|
NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.interval]};
|
|
284
328
|
|
|
285
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipBackward"
|
|
329
|
+
[self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipBackward"
|
|
330
|
+
eventBody:body];
|
|
286
331
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
287
332
|
}
|
|
288
333
|
|
|
289
|
-
- (MPRemoteCommandHandlerStatus)onChangePlaybackPosition:
|
|
334
|
+
- (MPRemoteCommandHandlerStatus)onChangePlaybackPosition:
|
|
335
|
+
(MPChangePlaybackPositionCommandEvent *)event
|
|
290
336
|
{
|
|
291
|
-
NSDictionary *body =
|
|
337
|
+
NSDictionary *body =
|
|
338
|
+
@{@"value" : [NSNumber numberWithDouble:event.positionTime]};
|
|
292
339
|
|
|
293
|
-
[self.audioAPIModule
|
|
340
|
+
[self.audioAPIModule
|
|
341
|
+
invokeHandlerWithEventName:@"remoteChangePlaybackPosition"
|
|
342
|
+
eventBody:body];
|
|
294
343
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
295
344
|
}
|
|
296
345
|
|