diff --git a/RNSound/RNSound.m b/RNSound/RNSound.m index 2dc3da93..aa363cff 100644 --- a/RNSound/RNSound.m +++ b/RNSound/RNSound.m @@ -79,7 +79,7 @@ -(void) audioPlayerDidFinishPlaying:(AVAudioPlayer*)player [self setOnPlay:NO forPlayerKey:key]; RCTResponseSenderBlock callback = [self callbackForKey:key]; if (callback) { - callback(@[@(flag)]); + callback([NSArray arrayWithObjects:[NSNumber numberWithBool:flag], nil]); [[self callbackPool] removeObjectForKey:key]; } } @@ -88,17 +88,17 @@ -(void) audioPlayerDidFinishPlaying:(AVAudioPlayer*)player RCT_EXPORT_MODULE(); -(NSArray *)supportedEvents - { - return @[@"onPlayChange"]; - } +{ + return [NSArray arrayWithObjects: @"onPlayChange", nil]; +} -(NSDictionary *)constantsToExport { - return @{@"IsAndroid": [NSNumber numberWithBool:NO], - @"MainBundlePath": [[NSBundle mainBundle] bundlePath], - @"NSDocumentDirectory": [self getDirectory:NSDocumentDirectory], - @"NSLibraryDirectory": [self getDirectory:NSLibraryDirectory], - @"NSCachesDirectory": [self getDirectory:NSCachesDirectory], - }; + return [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], @"IsAndroid", + [[NSBundle mainBundle] bundlePath], @"MainBundlePath", + [self getDirectory:NSDocumentDirectory], @"NSDocumentDirectory", + [self getDirectory:NSLibraryDirectory], @"NSLibraryDirectory", + [self getDirectory:NSCachesDirectory], @"NSCachesDirectory", nil]; } RCT_EXPORT_METHOD(enable:(BOOL)enabled) { @@ -208,10 +208,9 @@ -(NSDictionary *)constantsToExport { player.enableRate = YES; [player prepareToPlay]; [[self playerPool] setObject:player forKey:key]; - callback(@[[NSNull null], @{@"duration": @(player.duration), - @"numberOfChannels": @(player.numberOfChannels)}]); + callback([NSArray arrayWithObjects:[NSNull null], [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithDouble:player.duration], @"duration", [NSNumber numberWithUnsignedInteger:player.numberOfChannels], @"numberOfChannels", nil], nil]); } else { - callback(@[RCTJSErrorFromNSError(error)]); + callback([NSArray arrayWithObjects:RCTJSErrorFromNSError(error), nil]); } } @@ -231,7 +230,7 @@ -(NSDictionary *)constantsToExport { AVAudioPlayer* player = [self playerForKey:key]; if (player) { [player pause]; - callback(@[]); + callback([NSArray array]); } } @@ -240,7 +239,7 @@ -(NSDictionary *)constantsToExport { if (player) { [player stop]; player.currentTime = 0; - callback(@[]); + callback([NSArray array]); } } @@ -295,9 +294,9 @@ -(NSDictionary *)constantsToExport { withCallback:(RCTResponseSenderBlock)callback) { AVAudioPlayer* player = [self playerForKey:key]; if (player) { - callback(@[@(player.currentTime), @(player.isPlaying)]); + callback([NSArray arrayWithObjects:[NSNumber numberWithDouble:player.currentTime], [NSNumber numberWithBool: player.isPlaying], nil]); } else { - callback(@[@(-1), @(false)]); + callback([NSArray arrayWithObjects:[NSNumber numberWithInteger:-1], [NSNumber numberWithBool:NO], nil]); } } @@ -306,6 +305,6 @@ + (BOOL)requiresMainQueueSetup return YES; } - (void)setOnPlay:(BOOL)isPlaying forPlayerKey:(nonnull NSNumber*)playerKey { - [self sendEventWithName:@"onPlayChange" body:@{@"isPlaying": isPlaying ? @YES : @NO, @"playerKey": playerKey}]; + [self sendEventWithName:@"onPlayChange" body:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool: isPlaying ? YES : NO], @"isPlaying", playerKey, @"playerKey", nil]]; } @end diff --git a/android/build.gradle b/android/build.gradle index 5baea0df..172881a2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion 26 + buildToolsVersion "26.0.3" defaultConfig { minSdkVersion 16 - targetSdkVersion 23 + targetSdkVersion 26 versionCode 1 versionName "1.0" ndk {