Agora RTC Objective-C API Reference  Refactor
Instance Methods | Class Methods
AgoraMusicContentCenter Class Reference

Inherits <NSObject>.

Instance Methods

(NSInteger) - renewToken:
 
(NSInteger) - registerEventDelegate:
 
(id< AgoraMusicPlayerProtocol >) - createMusicPlayerWithDelegate:
 
(NSString *) - getMusicCharts
 
(NSString *) - getMusicCollectionWithMusicChartId:page:pageSize:jsonOption:
 
(NSString *) - searchMusicWithKeyWord:page:pageSize:jsonOption:
 
(NSInteger) - preloadWithSongCode:jsonOption:
 
(NSInteger) - isPreloadedWithSongCode:
 
(NSString *) - getLyricWithSongCode:lyricType:
 

Class Methods

(instancetype) + sharedContentCenterWithConfig:
 
(void) + destroy
 

Method Documentation

◆ sharedContentCenterWithConfig:

+ (instancetype) sharedContentCenterWithConfig: (AgoraMusicContentCenterConfig *)  config

Create an AgoraMusicContentCenter instance.

Parameters
configConfigurations for the AgoraMusicContentCenter instance. For details, see AgoraMusicContentCenterConfig.
Returns
An shared instance of AgoraMusicContentCenter

◆ renewToken:

- (NSInteger) renewToken: (NSString *_Nonnull)  token

Renew token of music content center

Parameters
tokenThe new token.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerEventDelegate:

- (NSInteger) registerEventDelegate: (id< AgoraMusicContentCenterEventDelegate > _Nullable)  eventDelegate

Register an event delegate, only the last delegate is working.

Parameters
eventDelegatethe object who need AgoraRtcMediaPlayerDelegate method to get the player information , if you want remove the delegate, just pass nil
Returns
  • 0: Success.
  • < 0: Failure.

◆ createMusicPlayerWithDelegate:

- (id<AgoraMusicPlayerProtocol>) createMusicPlayerWithDelegate: (id< AgoraRtcMediaPlayerDelegate >_Nullable)  delegate

Creates a music player source object and return its pointer.

Parameters
delegateThe object who need AgoraRtcMediaPlayerDelegate method to get the player information
Returns
  • The pointer to an object who realize the AgoraMusicPlayerProtocol, if the method call succeeds.
  • The empty pointer NULL, if the method call fails.

◆ getMusicCharts

- (NSString *) getMusicCharts

Get music chart collection of music.If the method call success, get result from the AgoraMusicContentCenterEventDelegate - (void)onMusicChartsResult:(NSString *)requestId status:(AgoraMusicContentCenterStatusCode)status result:(NSArray<AgoraMusicChartInfo*> *)result; match the callback "requestId" parameter to get the request result.

Returns
The request identification

◆ getMusicCollectionWithMusicChartId:page:pageSize:jsonOption:

- (NSString *) getMusicCollectionWithMusicChartId: (NSInteger)  musicChartId
page: (NSInteger)  page
pageSize: (NSInteger)  pageSize
jsonOption: (NSString *_Nullable)  jsonOption 

Get hot music list by hotType and page info.If the method call success, get result from the AgoraMusicContentCenterEventDelegate - (void)onMusicCollectionResult:(NSString *)requestId status:(AgoraMusicContentCenterStatusCode)status result:(AgoraMusicCollection *)result; match the callback "requestId" parameter to get the request result.

Parameters
musicChartIdThe music chart id obtained from getMusicCharts.
pageThe page of the music chart, starting from 1
pageSizeThe page size, max is 50.
jsonOptionThe ext param, default is null.
Returns
The request identification

◆ searchMusicWithKeyWord:page:pageSize:jsonOption:

- (NSString *) searchMusicWithKeyWord: (NSString *)  keyWord
page: (NSInteger)  page
pageSize: (NSInteger)  pageSize
jsonOption: (NSString *_Nullable)  jsonOption 

Search music by keyword and page info. get result from the AgoraMusicContentCenterEventDelegate - (void)onMusicCollectionResult:(NSString *)requestId status:(AgoraMusicContentCenterStatusCode)status result:(AgoraMusicCollection *)result; match the callback "requestId" parameter to get the request result.

Parameters
keyWordThe key word to search.
pageThe page of the music search result, starting from 1
pageSizeThe page size, max is 50.
jsonOptionThe ext param, default is null.
Returns
The request identification

◆ preloadWithSongCode:jsonOption:

- (NSInteger) preloadWithSongCode: (NSInteger)  songCode
jsonOption: (NSString *_Nullable)  jsonOption 

Preload a media file with specified parameters.

Parameters
songCodeThe identify of the media file that you want to play.
optionThe ext param, default is null.
Returns
  • 0: Success.
  • < 0: Failure.

◆ isPreloadedWithSongCode:

- (NSInteger) isPreloadedWithSongCode: (NSInteger)  songCode

Preload a media file with specified parameters.

Parameters
songCodeThe identify of the media file that you want to play.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getLyricWithSongCode:lyricType:

- (NSString *) getLyricWithSongCode: (NSInteger)  songCode
lyricType: (NSInteger)  lyricType 

Get lyric of the song. get result from the AgoraMusicContentCenterEventDelegate - (void)onLyricResult:(NSString*)requestId lyricUrl:(NSString*)lyricUrl; match the callback "requestId" parameter to get the request result.

Parameters
songCodeThe identify of the media file that you want to play.
LyricTypeThe type of the lyric file. may be 0:xml or 1:lrc.
Returns
The request identification

◆ destroy

+ (void) destroy

Destroy the shared instance of AgoraMusicContentCenter

Note
If you call the method, you should call it brefore AgoraRtcEngineKit destroy