11#import " MusicLibrary.h"
2+ #import " MusicLibrary-Swift.h"
23
3- @implementation MusicLibrary
4- RCT_EXPORT_MODULE ()
5-
6- - (NSNumber *)multiply:(double )a b:(double )b {
7- NSNumber *result = @(a * b);
4+ @implementation MusicLibrary {
5+ MusicLibraryImpl *musicLibrary;
6+ }
87
9- return result;
8+ - (instancetype ) init {
9+ if (self = [super init ]) {
10+ musicLibrary = [MusicLibraryImpl new ];
11+ }
12+ return self;
1013}
1114
1215- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule :
@@ -15,4 +18,47 @@ - (NSNumber *)multiply:(double)a b:(double)b {
1518 return std::make_shared<facebook::react::NativeMusicLibrarySpecJSI>(params);
1619}
1720
21+ - (void )getTracksAsync : (JS::NativeMusicLibrary::InternalTrackOptions &)options resolve : (nonnull RCTPromiseResolveBlock)resolve reject : (nonnull RCTPromiseRejectBlock)reject {
22+ NSDictionary *optionsDict = @{}; // Convert JS options to NSDictionary
23+ NSDictionary *result = [musicLibrary getTracksAsync: optionsDict];
24+ resolve (result);
25+ }
26+
27+ - (void )getTrackMetadataAsync : (nonnull NSString *)trackId resolve : (nonnull RCTPromiseResolveBlock)resolve reject : (nonnull RCTPromiseRejectBlock)reject {
28+ NSDictionary *result = [musicLibrary getTrackMetadataAsync: trackId];
29+ resolve (result);
30+ }
31+
32+ - (void )getTracksByAlbumAsync : (nonnull NSString *)albumId resolve : (nonnull RCTPromiseResolveBlock)resolve reject : (nonnull RCTPromiseRejectBlock)reject {
33+ NSArray *result = [musicLibrary getTracksByAlbumAsync: albumId];
34+ resolve (result);
35+ }
36+
37+ - (void )getTracksByArtistAsync : (nonnull NSString *)artistId options : (JS::NativeMusicLibrary::InternalTrackOptions &)options resolve : (nonnull RCTPromiseResolveBlock)resolve reject : (nonnull RCTPromiseRejectBlock)reject {
38+ NSDictionary *optionsDict = @{}; // Convert JS options to NSDictionary
39+ NSDictionary *result = [musicLibrary getTracksByArtistAsync: artistId options: optionsDict];
40+ resolve (result);
41+ }
42+
43+ - (void )getAlbumsAsync : (JS::NativeMusicLibrary::InternalAlbumOptions &)options resolve : (nonnull RCTPromiseResolveBlock)resolve reject : (nonnull RCTPromiseRejectBlock)reject {
44+ NSDictionary *optionsDict = @{}; // Convert JS options to NSDictionary
45+ NSDictionary *result = [musicLibrary getAlbumsAsync: optionsDict];
46+ resolve (result);
47+ }
48+
49+ - (void )getAlbumsByArtistAsync : (nonnull NSString *)artistId resolve : (nonnull RCTPromiseResolveBlock)resolve reject : (nonnull RCTPromiseRejectBlock)reject {
50+ NSArray *result = [musicLibrary getAlbumsByArtistAsync: artistId];
51+ resolve (result);
52+ }
53+
54+ - (void )getArtistsAsync : (JS::NativeMusicLibrary::InternalArtistOptions &)options resolve : (nonnull RCTPromiseResolveBlock)resolve reject : (nonnull RCTPromiseRejectBlock)reject {
55+ NSDictionary *optionsDict = @{}; // Convert JS options to NSDictionary
56+ NSDictionary *result = [musicLibrary getArtistsAsync: optionsDict];
57+ resolve (result);
58+ }
59+
60+ + (NSString *)moduleName {
61+ return @" MusicLibraryImpl" ;
62+ }
63+
1864@end
0 commit comments