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
11 @protocol AgoraRtcMediaPlayerProtocol;
12 @protocol AgoraRtcMediaPlayerDelegate;
13
17 typedef NS_ENUM(NSUInteger, AgoraMusicPlayMode) {
21 AgoraMusicPlayModeOriginal = 0,
22
26 AgoraMusicPlayModeAccompany = 1,
30 AgoraMusicPlayModeLeadsing = 2,
31 };
32
36 typedef NS_ENUM(NSUInteger, AgoraMusicContentCenterPreloadState) {
40 AgoraMusicContentCenterPreloadStateOK = 0,
41
45 AgoraMusicContentCenterPreloadStateError = 1,
46
50 AgoraMusicContentCenterPreloadStatePreloading = 2,
51
55 AgoraMusicContentCenterPreloadStateRemoveCache = 3,
56 };
57
61 typedef NS_ENUM(NSUInteger, AgoraMusicContentCenterStateReason) {
65 AgoraMusicContentCenterStateReasonOK = 0,
69 AgoraMusicContentCenterStateReasonError = 1,
76 AgoraMusicContentCenterStateReasonErrorGateway = 2,
81 AgoraMusicContentCenterStateReasonErrorPermissionAndResource = 3,
85 AgoraMusicContentCenterStateReasonErrorInternalDataParse = 4,
89 AgoraMusicContentCenterStateReasonErrorMusicLoading = 5,
93 AgoraMusicContentCenterStateReasonErrorMusicDecryption = 6,
97 AgoraMusicContentCenterStateReasonErrorHttpInternalError = 7,
98 };
99
103 typedef NS_ENUM(NSUInteger, AgoraMusicCacheStatusType) {
107 AgoraMusicCacheStatusTypeCached = 0,
108
112 AgoraMusicCacheStatusTypeCaching = 1,
113 };
114
115 NS_ASSUME_NONNULL_BEGIN
116
120 __attribute__((visibility("default"))) @interface AgoraMusicCacheInfo : NSObject
124 @property(nonatomic, assign) NSInteger songCode;
125
129 @property(nonatomic, assign) AgoraMusicCacheStatusType statusType;
130 @end
131
135 __attribute__((visibility("default"))) @interface AgoraMusicChartInfo : NSObject
139 @property (nonatomic, copy) NSString *chartName;
143 @property (nonatomic, assign) NSInteger identify;
144 @end
145
146 __attribute__((visibility("default"))) @interface AgoraMvProperty : NSObject
150 @property (nonatomic, copy) NSString *resolution;
154 @property (nonatomic, copy) NSString *bandwidth;
155 @end
156
160 __attribute__((visibility("default"))) @interface AgoraClimaxSegment : NSObject
164 @property(nonatomic, assign) NSInteger startTimeMs;
168 @property(nonatomic, assign) NSInteger endTimeMs;
169 @end
170
174 __attribute__((visibility("default"))) @interface AgoraMusic : NSObject
178 @property(nonatomic, assign) NSInteger songCode;
187 @property(nonatomic, assign) NSInteger type;
193 @property(nonatomic, assign) NSInteger pitchType;
197 @property(nonatomic, copy) NSString* name;
201 @property(nonatomic, copy) NSString* singer;
205 @property(nonatomic, copy) NSString* poster;
206
210 @property(nonatomic, copy) NSString* releaseTime;
214 @property(nonatomic, assign) NSInteger durationS;
220 @property(nonatomic, strong) NSArray<NSNumber *>* lyricList;
224 @property(nonatomic, strong) NSArray<AgoraMvProperty *>* mvPropertyList;
228 @property(nonatomic, strong) NSArray<AgoraClimaxSegment *>* climaxSegmentList;
229 @end
230
234 __attribute__((visibility("default"))) @interface AgoraMusicCollection : NSObject
238 @property(nonatomic, assign) NSInteger count;
242 @property(nonatomic, assign) NSInteger total;
246 @property(nonatomic, assign) NSInteger page;
250 @property(nonatomic, assign) NSInteger pageSize;
255 @property(nonatomic, strong) NSArray<AgoraMusic *>* musicList;
256 @end
257
261 @protocol AgoraMusicContentCenterEventDelegate <NSObject>
275 - (void)onMusicChartsResult:(NSString *)requestId result:(NSArray<AgoraMusicChartInfo*> *)result reason:(AgoraMusicContentCenterStateReason)reason;
276
292 - (void)onMusicCollectionResult:(NSString *)requestId result:(AgoraMusicCollection *)result reason:(AgoraMusicContentCenterStateReason)reason;
293
308 - (void)onLyricResult:(NSString*)requestId songCode:(NSInteger)songCode lyricUrl:(NSString* _Nullable)lyricUrl reason:(AgoraMusicContentCenterStateReason)reason;
309
329 - (void)onSongSimpleInfoResult:(NSString*)requestId songCode:(NSInteger)songCode simpleInfo:(NSString* _Nullable)simpleInfo reason:(AgoraMusicContentCenterStateReason)reason;
330
348 - (void)onPreLoadEvent:(NSString*)requestId songCode:(NSInteger)songCode percent:(NSInteger)percent lyricUrl:(NSString * _Nullable)lyricUrl state:(AgoraMusicContentCenterPreloadState)state reason:(AgoraMusicContentCenterStateReason)reason;
349 @end
350
351
352 @class AgoraRtcEngineKit;
356 __attribute__((visibility("default"))) @interface AgoraMusicContentCenterConfig : NSObject
360 @property(assign, nonatomic) AgoraRtcEngineKit* _Nullable rtcEngine;
364 @property (nonatomic, copy) NSString *appId;
372 @property (nonatomic, copy) NSString *token;
377 @property (nonatomic, assign) NSInteger mccUid;
381 @property (nonatomic, assign) NSUInteger maxCacheSize;
385 @property(nonatomic, copy) NSString* mccDomain;
389 @property(nonatomic, weak) id<AgoraMusicContentCenterEventDelegate> eventDelegate;
390 @end
391
392 @protocol AgoraMusicPlayerProtocol <AgoraRtcMediaPlayerProtocol>
418 - (NSInteger)openMediaWithSongCode:(NSInteger)songCode startPos:(NSInteger)startPos NS_SWIFT_NAME(openMedia(songCode:startPos:));
419
443 - (NSInteger)setPlayMode:(AgoraMusicPlayMode)mode NS_SWIFT_NAME(setPlayMode(mode:));
444
445 @end
446
447
448 __attribute__((visibility("default"))) @interface AgoraMusicContentCenter : NSObject
449
464 + (instancetype _Nullable)sharedContentCenterWithConfig:(AgoraMusicContentCenterConfig *)config NS_SWIFT_NAME(sharedContentCenter(config:));
465
479 - (NSInteger)renewToken:(NSString * _Nonnull)token;
480
492 - (NSInteger)registerEventDelegate:(id<AgoraMusicContentCenterEventDelegate> _Nullable)eventDelegate;
493
507 - (id<AgoraMusicPlayerProtocol> _Nullable)createMusicPlayerWithDelegate:(id<AgoraRtcMediaPlayerDelegate> _Nullable)delegate NS_SWIFT_NAME(createMusicPlayer(delegate:));
508
526 - (NSInteger)destroyMusicPlayer:(id<AgoraMusicPlayerProtocol>)musicPlayer;
527
538 - (NSString *)getMusicCharts;
539
565 - (NSString *)getMusicCollectionWithMusicChartId:(NSInteger)musicChartId page:(NSInteger)page pageSize:(NSInteger)pageSize jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(getMusicCollection(musicChartId:page:pageSize:jsonOption:));
566
590 - (NSString *)searchMusicWithKeyWord:(NSString *)keyWord page:(NSInteger)page pageSize:(NSInteger)pageSize jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(searchMusic(keyWord:page:pageSize:jsonOption:));
591
630 - (NSInteger)preloadWithSongCode:(NSInteger)songCode jsonOption:(NSString* _Nullable)jsonOption NS_SWIFT_NAME(preload(songCode:jsonOption:)) __attribute__((deprecated("Use preload(songCode:) instead.")));
631
655 - (NSString *)preloadWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(preload(songCode:));
656
670 - (NSInteger)isPreloadedWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(isPreloaded(songCode:));
671
687 - (NSInteger)removeCacheWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(removeCache(songCode:));
688
704 - (NSArray *)getCaches NS_SWIFT_NAME(getCaches());
705
731 - (NSInteger)getInternalSongCode:(NSInteger)songCode jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(getInternalSongCode(songCode:jsonOption:));
732
748 - (NSString *)getLyricWithSongCode:(NSInteger)songCode lyricType:(NSInteger)lyricType NS_SWIFT_NAME(getLyric(songCode:lyricType:));
749
769 - (NSString *)getSongSimpleInfoWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(getSongSimpleInfo(songCode:));
770
785 - (void)enableMainQueueDispatch:(BOOL)enabled;
786
794 + (void)destroy;
795
796
797 #pragma mark - Unavailable Delegate Methods
798 #if TARGET_OS_IPHONE
799 - (void)onMusicChartsResult:(NSString *)requestId result:(NSArray<AgoraMusicChartInfo*> *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(ios,deprecated=7_0,message="Use onMusicChartsResult:result:statusCode: instead.")));
800 - (void)onMusicCollectionResult:(NSString *)requestId result:(AgoraMusicCollection *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(ios,deprecated=7_0,message="Use onMusicCollectionResult:result:statusCode: instead.")));
801 - (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.")));
802 - (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.")));
803 - (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.")));
804 #endif
805
806 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
807 - (void)onMusicChartsResult:(NSString *)requestId result:(NSArray<AgoraMusicChartInfo*> *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(macos,deprecated=10_9,message="Use onMusicChartsResult:result:statusCode: instead.")));
808 - (void)onMusicCollectionResult:(NSString *)requestId result:(AgoraMusicCollection *)result errorCode:(AgoraMusicContentCenterStateReason)errorCode __attribute__((availability(macos,deprecated=10_9,message="Use onMusicCollectionResult:result:statusCode: instead.")));
809 - (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.")));
810 - (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.")));
811 - (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.")));
812 #endif
813
814 @end
815
816 NS_ASSUME_NONNULL_END
AgoraRtcEngineKit
Definition: AgoraRtcEngineKit.h:48
AgoraMusicCacheInfo::songCode
NSInteger songCode
Definition: AgoraMusicContentCenter.h:124
AgoraMusicContentCenterPreloadStateRemoveCache
@ AgoraMusicContentCenterPreloadStateRemoveCache
Definition: AgoraMusicContentCenter.h:55
AgoraMusicCacheStatusTypeCaching
@ AgoraMusicCacheStatusTypeCaching
Definition: AgoraMusicContentCenter.h:112
AgoraMusicContentCenterStateReasonErrorMusicDecryption
@ AgoraMusicContentCenterStateReasonErrorMusicDecryption
Definition: AgoraMusicContentCenter.h:93
AgoraMusicContentCenterStateReason
AgoraMusicContentCenterStateReason
Request status codes for the music content center.
Definition: AgoraMusicContentCenter.h:61
AgoraMusicCacheStatusTypeCached
@ AgoraMusicCacheStatusTypeCached
Definition: AgoraMusicContentCenter.h:107
AgoraMusicContentCenterStateReasonErrorGateway
@ AgoraMusicContentCenterStateReasonErrorGateway
Definition: AgoraMusicContentCenter.h:76
AgoraMusicContentCenterConfig
Settings for the music content center.
Definition: AgoraMusicContentCenter.h:357
AgoraMusicCacheInfo
Information about cached Copyright music resources.
Definition: AgoraMusicContentCenter.h:121
AgoraMusicContentCenterStateReasonErrorInternalDataParse
@ AgoraMusicContentCenterStateReasonErrorInternalDataParse
Definition: AgoraMusicContentCenter.h:85
AgoraMusicChartInfo
Detailed information of the music chart.
Definition: AgoraMusicContentCenter.h:136
-[AgoraMusicContentCenter getCaches]
NSArray * getCaches()
Gets information about the cached music resources.
+[AgoraMusicContentCenter destroy]
void destroy()
Destroys the AgoraMusicContentCenter instance.
AgoraMusicPlayModeOriginal
@ AgoraMusicPlayModeOriginal
Definition: AgoraMusicContentCenter.h:21
AgoraMusicContentCenterPreloadStateError
@ AgoraMusicContentCenterPreloadStateError
Definition: AgoraMusicContentCenter.h:45
AgoraRtcMediaPlayerProtocol-p
Definition: AgoraRtcMediaPlayerProtocol.h:24
AgoraMusicContentCenter
Definition: AgoraMusicContentCenter.h:449
AgoraMusic
Detailed information about the music resource.
Definition: AgoraMusicContentCenter.h:175
AgoraMvProperty
Definition: AgoraMusicContentCenter.h:147
AgoraMusicContentCenterStateReasonErrorMusicLoading
@ AgoraMusicContentCenterStateReasonErrorMusicLoading
Definition: AgoraMusicContentCenter.h:89
AgoraMusicPlayModeAccompany
@ AgoraMusicPlayModeAccompany
Definition: AgoraMusicContentCenter.h:26
AgoraRtcMediaPlayerDelegate-p
Definition: AgoraRtcMediaPlayerDelegate.h:11
AgoraMusicCacheInfo::statusType
AgoraMusicCacheStatusType statusType
Definition: AgoraMusicContentCenter.h:129
AgoraMusicContentCenterPreloadStateOK
@ AgoraMusicContentCenterPreloadStateOK
Definition: AgoraMusicContentCenter.h:40
AgoraMusicContentCenterPreloadState
AgoraMusicContentCenterPreloadState
The loading state of music resources.
Definition: AgoraMusicContentCenter.h:36
AgoraMusicContentCenterStateReasonErrorPermissionAndResource
@ AgoraMusicContentCenterStateReasonErrorPermissionAndResource
Definition: AgoraMusicContentCenter.h:81
-[AgoraMusicContentCenter getMusicCharts]
NSString * getMusicCharts()
Retrieves all music charts.
AgoraMusicCollection
Detailed information of the music resource list.
Definition: AgoraMusicContentCenter.h:235
AgoraMusicContentCenterStateReasonError
@ AgoraMusicContentCenterStateReasonError
Definition: AgoraMusicContentCenter.h:69
AgoraClimaxSegment
The climax parts of the music.
Definition: AgoraMusicContentCenter.h:161
AgoraMusicContentCenterEventDelegate-p
Definition: AgoraMusicContentCenter.h:261
AgoraMusicPlayModeLeadsing
@ AgoraMusicPlayModeLeadsing
Definition: AgoraMusicContentCenter.h:30
AgoraMusicContentCenterPreloadStatePreloading
@ AgoraMusicContentCenterPreloadStatePreloading
Definition: AgoraMusicContentCenter.h:50
AgoraMusicPlayMode
AgoraMusicPlayMode
Playback modes for music resources.
Definition: AgoraMusicContentCenter.h:17
AgoraMusicPlayerProtocol-p
Definition: AgoraMusicContentCenter.h:392
AgoraMusicContentCenterStateReasonErrorHttpInternalError
@ AgoraMusicContentCenterStateReasonErrorHttpInternalError
Definition: AgoraMusicContentCenter.h:97
AgoraMusicCacheStatusType
AgoraMusicCacheStatusType
The cache state of music resources.
Definition: AgoraMusicContentCenter.h:103
AgoraMusicContentCenterStateReasonOK
@ AgoraMusicContentCenterStateReasonOK
Definition: AgoraMusicContentCenter.h:65