Agora RTC Objective-C API Reference  Refactor
AgoraMusicContentCenter.h
Go to the documentation of this file.
1 //
2 // AgoraMusicContentCenter.h
3 // AgoraMusicContentCenter
4 //
5 // Created by dingyusong on 2022/6/1.
6 // Copyright © 2022 Agora. All rights reserved.
7 //
8 
9 #import <Foundation/Foundation.h>
10 
13 
17 typedef NS_ENUM(NSUInteger, AgoraMusicPlayMode) {
22 
31 };
32 
36 typedef NS_ENUM(NSUInteger, AgoraMusicContentCenterPreloadState) {
41 
46 
51 
56 };
57 
61 typedef NS_ENUM(NSUInteger, AgoraMusicContentCenterStateReason) {
102 };
103 
104 typedef NS_ENUM(NSUInteger, AgoraMusicCacheStatusType) {
109 
114 };
115 
116 NS_ASSUME_NONNULL_BEGIN
117 
118 __attribute__((visibility("default"))) @interface AgoraMusicCacheInfo : NSObject
122 @property(nonatomic, assign) NSInteger songCode;
123 
127 @property(nonatomic, assign) AgoraMusicCacheStatusType statusType;
128 @end
129 
130 __attribute__((visibility("default"))) @interface AgoraMusicChartInfo : NSObject
134 @property (nonatomic, copy) NSString *chartName;
138 @property (nonatomic, assign) NSInteger identify;
139 @end
140 
141 __attribute__((visibility("default"))) @interface AgoraMvProperty : NSObject
145 @property (nonatomic, copy) NSString *resolution;
149 @property (nonatomic, copy) NSString *bandwidth;
150 @end
151 
152 __attribute__((visibility("default"))) @interface AgoraClimaxSegment : NSObject
156 @property(nonatomic, assign) NSInteger startTimeMs;
160 @property(nonatomic, assign) NSInteger endTimeMs;
161 @end
162 
166 __attribute__((visibility("default"))) @interface AgoraMusic : NSObject
170 @property(nonatomic, assign) NSInteger songCode;
181 @property(nonatomic, assign) NSInteger type;
187 @property(nonatomic, assign) NSInteger pitchType;
191 @property(nonatomic, copy) NSString* name;
195 @property(nonatomic, copy) NSString* singer;
199 @property(nonatomic, copy) NSString* poster;
200 
204 @property(nonatomic, copy) NSString* releaseTime;
208 @property(nonatomic, assign) NSInteger durationS;
214 @property(nonatomic, strong) NSArray<NSNumber *>* lyricList;
218 @property(nonatomic, strong) NSArray<AgoraMvProperty *>* mvPropertyList;
222 @property(nonatomic, strong) NSArray<AgoraClimaxSegment *>* climaxSegmentList;
223 @end
224 
228 __attribute__((visibility("default"))) @interface AgoraMusicCollection : NSObject
232 @property(nonatomic, assign) NSInteger count;
236 @property(nonatomic, assign) NSInteger total;
240 @property(nonatomic, assign) NSInteger page;
244 @property(nonatomic, assign) NSInteger pageSize;
248 @property(nonatomic, strong) NSArray<AgoraMusic *>* musicList;
249 @end
250 
262 - (void)onMusicChartsResult:(NSString *)requestId result:(NSArray<AgoraMusicChartInfo*> *)result reason:(AgoraMusicContentCenterStateReason)reason;
263 
271 - (void)onMusicCollectionResult:(NSString *)requestId result:(AgoraMusicCollection *)result reason:(AgoraMusicContentCenterStateReason)reason;
272 
281 - (void)onLyricResult:(NSString*)requestId songCode:(NSInteger)songCode lyricUrl:(NSString* _Nullable)lyricUrl reason:(AgoraMusicContentCenterStateReason)reason;
282 
291 - (void)onSongSimpleInfoResult:(NSString*)requestId songCode:(NSInteger)songCode simpleInfo:(NSString* _Nullable)simpleInfo reason:(AgoraMusicContentCenterStateReason)reason;
292 
303 - (void)onPreLoadEvent:(NSString*)requestId songCode:(NSInteger)songCode percent:(NSInteger)percent lyricUrl:(NSString * _Nullable)lyricUrl state:(AgoraMusicContentCenterPreloadState)state reason:(AgoraMusicContentCenterStateReason)reason;
304 @end
305 
306 
307 @class AgoraRtcEngineKit;
308 __attribute__((visibility("default"))) @interface AgoraMusicContentCenterConfig : NSObject
309 @property(assign, nonatomic) AgoraRtcEngineKit* _Nullable rtcEngine;
313 @property (nonatomic, copy) NSString *appId;
317 @property (nonatomic, copy) NSString *token;
321 @property (nonatomic, assign) NSInteger mccUid;
325 @property (nonatomic, assign) NSUInteger maxCacheSize;
329 @property(nonatomic, copy) NSString* mccDomain;
333 @property(nonatomic, weak) id<AgoraMusicContentCenterEventDelegate> eventDelegate;
334 @end
335 
346 - (NSInteger)openMediaWithSongCode:(NSInteger)songCode startPos:(NSInteger)startPos NS_SWIFT_NAME(openMedia(songCode:startPos:));
347 
358 - (NSInteger)setPlayMode:(AgoraMusicPlayMode)mode NS_SWIFT_NAME(setPlayMode(mode:));
359 
360 @end
361 
362 
363 __attribute__((visibility("default"))) @interface AgoraMusicContentCenter : NSObject
364 
371 + (instancetype _Nullable)sharedContentCenterWithConfig:(AgoraMusicContentCenterConfig *)config NS_SWIFT_NAME(sharedContentCenter(config:));
372 
380 - (NSInteger)renewToken:(NSString * _Nonnull)token;
381 
391 - (NSInteger)registerEventDelegate:(id<AgoraMusicContentCenterEventDelegate> _Nullable)eventDelegate;
392 
401 - (id<AgoraMusicPlayerProtocol> _Nullable)createMusicPlayerWithDelegate:(id<AgoraRtcMediaPlayerDelegate> _Nullable)delegate NS_SWIFT_NAME(createMusicPlayer(delegate:));
402 
411 - (NSInteger)destroyMusicPlayer:(id<AgoraMusicPlayerProtocol>)musicPlayer;
412 
418 - (NSString *)getMusicCharts;
419 
429 - (NSString *)getMusicCollectionWithMusicChartId:(NSInteger)musicChartId page:(NSInteger)page pageSize:(NSInteger)pageSize jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(getMusicCollection(musicChartId:page:pageSize:jsonOption:));
430 
440 - (NSString *)searchMusicWithKeyWord:(NSString *)keyWord page:(NSInteger)page pageSize:(NSInteger)pageSize jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(searchMusic(keyWord:page:pageSize:jsonOption:));
441 
452 - (NSInteger)preloadWithSongCode:(NSInteger)songCode jsonOption:(NSString* _Nullable)jsonOption NS_SWIFT_NAME(preload(songCode:jsonOption:)) __attribute__((deprecated("Use preload(songCode:) instead.")));
453 
460 - (NSString *)preloadWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(preload(songCode:));
461 
470 - (NSInteger)isPreloadedWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(isPreloaded(songCode:));
471 
480 - (NSInteger)removeCacheWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(removeCache(songCode:));
481 
487 - (NSArray *)getCaches NS_SWIFT_NAME(getCaches());
488 
498 - (NSInteger)getInternalSongCode:(NSInteger)songCode jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(getInternalSongCode(songCode:jsonOption:));
499 
507 - (NSString *)getLyricWithSongCode:(NSInteger)songCode lyricType:(NSInteger)lyricType NS_SWIFT_NAME(getLyric(songCode:lyricType:));
508 
515 - (NSString *)getSongSimpleInfoWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(getSongSimpleInfo(songCode:));
516 
522 - (void)enableMainQueueDispatch:(BOOL)enabled;
523 
529 + (void)destroy;
530 
531 
532 #pragma mark - Unavailable Delegate Methods
533 #if TARGET_OS_IPHONE
534 - (void)onMusicChartsResult:(NSString *)requestId result:(NSArray<AgoraMusicChartInfo*> *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(ios,deprecated=7_0,message="Use onMusicChartsResult:result:statusCode: instead.")));
535 - (void)onMusicCollectionResult:(NSString *)requestId result:(AgoraMusicCollection *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(ios,deprecated=7_0,message="Use onMusicCollectionResult:result:statusCode: instead.")));
536 - (void)onLyricResult:(NSString*)requestId songCode:(NSInteger)songCode lyricUrl:(NSString* _Nullable)lyricUrl errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(ios,deprecated=7_0,message="Use onLyricResult:songCode:lyricUrl:statusCode: instead.")));
537 - (void)onSongSimpleInfoResult:(NSString*)requestId songCode:(NSInteger)songCode simpleInfo:(NSString* _Nullable)simpleInfo errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(ios,deprecated=7_0,message="Use onSongSimpleInfoResult:songCode:simpleInfo:statusCode: instead.")));
538 - (void)onPreLoadEvent:(NSString*)requestId songCode:(NSInteger)songCode percent:(NSInteger)percent lyricUrl:(NSString * _Nullable)lyricUrl state:(AgoraMusicContentCenterPreloadState)state errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(ios,deprecated=7_0,message="Use onPreLoadEvent:songCode:percent:lyricUrl:status:statusCode: instead.")));
539 #endif
540 
541 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
542 - (void)onMusicChartsResult:(NSString *)requestId result:(NSArray<AgoraMusicChartInfo*> *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(macos,deprecated=10_9,message="Use onMusicChartsResult:result:statusCode: instead.")));
543 - (void)onMusicCollectionResult:(NSString *)requestId result:(AgoraMusicCollection *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(macos,deprecated=10_9,message="Use onMusicCollectionResult:result:statusCode: instead.")));
544 - (void)onLyricResult:(NSString*)requestId songCode:(NSInteger)songCode lyricUrl:(NSString* _Nullable)lyricUrl errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(macos,deprecated=10_9,message="Use onLyricResult:songCode:lyricUrl:statusCode: instead.")));
545 - (void)onSongSimpleInfoResult:(NSString*)requestId songCode:(NSInteger)songCode simpleInfo:(NSString* _Nullable)simpleInfo errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(macos,deprecated=10_9,message="Use onSongSimpleInfoResult:songCode:simpleInfo:statusCode: instead.")));
546 - (void)onPreLoadEvent:(NSString*)requestId songCode:(NSInteger)songCode percent:(NSInteger)percent lyricUrl:(NSString * _Nullable)lyricUrl state:(AgoraMusicContentCenterPreloadState)state errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(macos,deprecated=10_9,message="Use onPreLoadEvent:songCode:percent:lyricUrl:status:statusCode: instead.")));
547 #endif
548 
549 @end
550 
551 NS_ASSUME_NONNULL_END
AgoraRtcEngineKit
Definition: AgoraRtcEngineKit.h:47
AgoraMusicCacheInfo::songCode
NSInteger songCode
Definition: AgoraMusicContentCenter.h:122
AgoraMusicContentCenterPreloadStateRemoveCache
@ AgoraMusicContentCenterPreloadStateRemoveCache
Definition: AgoraMusicContentCenter.h:55
AgoraMusicCacheStatusTypeCaching
@ AgoraMusicCacheStatusTypeCaching
Definition: AgoraMusicContentCenter.h:113
AgoraMusicContentCenterStateReasonErrorMusicDecryption
@ AgoraMusicContentCenterStateReasonErrorMusicDecryption
Definition: AgoraMusicContentCenter.h:97
AgoraMusicContentCenterStateReason
AgoraMusicContentCenterStateReason
Definition: AgoraMusicContentCenter.h:61
AgoraMusicCacheStatusTypeCached
@ AgoraMusicCacheStatusTypeCached
Definition: AgoraMusicContentCenter.h:108
AgoraMusicContentCenterStateReasonErrorGateway
@ AgoraMusicContentCenterStateReasonErrorGateway
Definition: AgoraMusicContentCenter.h:79
AgoraMusicContentCenterConfig
Definition: AgoraMusicContentCenter.h:309
AgoraMusicCacheInfo
Definition: AgoraMusicContentCenter.h:119
AgoraMusicContentCenterStateReasonErrorInternalDataParse
@ AgoraMusicContentCenterStateReasonErrorInternalDataParse
Definition: AgoraMusicContentCenter.h:89
AgoraMusicChartInfo
Definition: AgoraMusicContentCenter.h:131
-[AgoraMusicContentCenter getCaches]
NSArray * getCaches()
+[AgoraMusicContentCenter destroy]
void destroy()
AgoraMusicPlayModeOriginal
@ AgoraMusicPlayModeOriginal
Definition: AgoraMusicContentCenter.h:21
AgoraMusicContentCenterPreloadStateError
@ AgoraMusicContentCenterPreloadStateError
Definition: AgoraMusicContentCenter.h:45
AgoraRtcMediaPlayerProtocol-p
Definition: AgoraRtcMediaPlayerProtocol.h:24
AgoraMusicContentCenter
Definition: AgoraMusicContentCenter.h:364
AgoraMusic
Definition: AgoraMusicContentCenter.h:167
AgoraMvProperty
Definition: AgoraMusicContentCenter.h:142
AgoraMusicContentCenterStateReasonErrorMusicLoading
@ AgoraMusicContentCenterStateReasonErrorMusicLoading
Definition: AgoraMusicContentCenter.h:93
AgoraMusicPlayModeAccompany
@ AgoraMusicPlayModeAccompany
Definition: AgoraMusicContentCenter.h:26
AgoraRtcMediaPlayerDelegate-p
Definition: AgoraRtcMediaPlayerDelegate.h:11
AgoraMusicCacheInfo::statusType
AgoraMusicCacheStatusType statusType
Definition: AgoraMusicContentCenter.h:127
AgoraMusicContentCenterPreloadStateOK
@ AgoraMusicContentCenterPreloadStateOK
Definition: AgoraMusicContentCenter.h:40
AgoraMusicContentCenterPreloadState
AgoraMusicContentCenterPreloadState
Definition: AgoraMusicContentCenter.h:36
AgoraMusicContentCenterStateReasonErrorPermissionAndResource
@ AgoraMusicContentCenterStateReasonErrorPermissionAndResource
Definition: AgoraMusicContentCenter.h:85
-[AgoraMusicContentCenter getMusicCharts]
NSString * getMusicCharts()
AgoraMusicCollection
Definition: AgoraMusicContentCenter.h:229
AgoraMusicContentCenterStateReasonError
@ AgoraMusicContentCenterStateReasonError
Definition: AgoraMusicContentCenter.h:72
AgoraClimaxSegment
Definition: AgoraMusicContentCenter.h:153
AgoraMusicContentCenterEventDelegate-p
Definition: AgoraMusicContentCenter.h:254
AgoraMusicPlayModeLeadsing
@ AgoraMusicPlayModeLeadsing
Definition: AgoraMusicContentCenter.h:30
AgoraMusicContentCenterPreloadStatePreloading
@ AgoraMusicContentCenterPreloadStatePreloading
Definition: AgoraMusicContentCenter.h:50
AgoraMusicPlayMode
AgoraMusicPlayMode
Definition: AgoraMusicContentCenter.h:17
AgoraMusicPlayerProtocol-p
Definition: AgoraMusicContentCenter.h:336
AgoraMusicContentCenterStateReasonErrorHttpInternalError
@ AgoraMusicContentCenterStateReasonErrorHttpInternalError
Definition: AgoraMusicContentCenter.h:101
AgoraMusicCacheStatusType
AgoraMusicCacheStatusType
Definition: AgoraMusicContentCenter.h:104
AgoraMusicContentCenterStateReasonOK
@ AgoraMusicContentCenterStateReasonOK
Definition: AgoraMusicContentCenter.h:65