|
Agora RTC Objective-C API Reference
Refactor
|
Inherits <NSObject>.
Instance Methods | |
| (NSInteger) | - renewToken: |
| (NSInteger) | - registerEventDelegate: |
| (id< AgoraMusicPlayerProtocol > _Nullable) | - createMusicPlayerWithDelegate: |
| (NSInteger) | - destroyMusicPlayer: |
| (NSString *) | - getMusicCharts |
| (NSString *) | - getMusicCollectionWithMusicChartId:page:pageSize:jsonOption: |
| (NSString *) | - searchMusicWithKeyWord:page:pageSize:jsonOption: |
| (NSInteger) | - preloadWithSongCode:jsonOption: |
| (NSString *) | - preloadWithSongCode: |
| (NSInteger) | - isPreloadedWithSongCode: |
| (NSInteger) | - removeCacheWithSongCode: |
| (NSArray *) | - getCaches |
| (NSInteger) | - getInternalSongCode:jsonOption: |
| (NSString *) | - getLyricWithSongCode:lyricType: |
| (NSString *) | - getSongSimpleInfoWithSongCode: |
Class Methods | |
| (instancetype _Nullable) | + sharedContentCenterWithConfig: |
| (void) | + destroy |
| + (instancetype _Nullable) sharedContentCenterWithConfig: | (AgoraMusicContentCenterConfig *) | config |
Initializes AgoraMusicContentCenter.
You must call this method to initialize AgoraMusicContentCenter before calling any other methods under the AgoraMusicContentCenter class.
| config | The configuration for AgoraMusicContentCenter. See AgoraMusicContentCenterConfig for details. |
AgoraMusicContentCenter instance.| - (NSInteger) renewToken: | (NSString *_Nonnull) | token |
Renews the Token.
When the Token used for authentication is about to expire or has already expired, you can call this method to pass in a newly generated Token.
| token | The new Token. |
Error Codes for details and troubleshooting suggestions. | - (NSInteger) registerEventDelegate: | (id< AgoraMusicContentCenterEventDelegate > _Nullable) | eventDelegate |
Registers the callback events for the music content center.
| eventDelegate | The callback event to be registered. See AgoraMusicContentCenterEventDelegate for details. Pass in nil if you want to remove a previously registered callback event. |
Error Codes for details and troubleshooting advice. | - (id<AgoraMusicPlayerProtocol> _Nullable) createMusicPlayerWithDelegate: | (id< AgoraRtcMediaPlayerDelegate > _Nullable) | delegate |
Creates a music player.
If you need to play music resources from the Copyright music center, you must call this method first to create a music player.
| delegate | See AgoraRtcMediaPlayerDelegate. |
AgoraMusicPlayerProtocol instance.| - (NSInteger) destroyMusicPlayer: | (id< AgoraMusicPlayerProtocol >) | musicPlayer |
Destroys the music player object.
When you no longer need to use the music player, you can call this method to destroy the music player object. If you need to use the music player again after destruction, you must call createMusicPlayerWithDelegate: to create a new music player object. Call timing: You can call this method either before or after joining a channel, but make sure to call it before the destroy method of AgoraRtcEngineKit.
| musicPlayer | The AgoraMusicPlayerProtocol object. |
Error Codes for details and troubleshooting suggestions. | - (NSString *) getMusicCharts |
Retrieves all music charts.
When you call this method, the SDK triggers the onMusicChartsResult:result:reason: callback to report detailed information about the music charts.
requestId that uniquely identifies this request. | - (NSString *) getMusicCollectionWithMusicChartId: | (NSInteger) | musicChartId | |
| page: | (NSInteger) | page | |
| pageSize: | (NSInteger) | pageSize | |
| jsonOption: | (NSString *_Nullable) | jsonOption | |
Retrieves the list of music resources from a specified music chart by its ID.
After this method is successfully called, the SDK triggers the onMusicCollectionResult:result:reason: callback to report detailed information about the music resources in the chart.
| musicChartId | The ID of the music chart, which can be obtained through the onMusicChartsResult:result:reason: callback. You can also use the RESTful API to retrieve the complete music library or retrieve the incremental music list. | |||||||||
| page | The current page number, starting from 1 by default. | |||||||||
| pageSize | The total number of pages of the current music resource list. The maximum value is 50. | |||||||||
| jsonOption | An optional JSON extension field, default is nil. You can use this field to filter the music resources you need. Currently supports filtering music resources that support scoring and music resources with chorus segments:
|
requestId that uniquely identifies this request. | - (NSString *) searchMusicWithKeyWord: | (NSString *) | keyWord | |
| page: | (NSInteger) | page | |
| pageSize: | (NSInteger) | pageSize | |
| jsonOption: | (NSString *_Nullable) | jsonOption | |
Search for music resources.
After this method is successfully called, the SDK triggers the onMusicCollectionResult:result:reason: callback to report the retrieved list of music resources.
| keyword | The search keyword. Supports searching by song title or artist name. | |||||||||
| page | The target page number of the music resource list you want to retrieve. | |||||||||
| pageSize | The maximum number of music resources displayed per page. The maximum value is 50. | |||||||||
| jsonOption | An optional extended JSON field, default is nil. You can use this field to filter the music resources you need. Currently, it supports filtering music resources that are scorable and those with chorus segments:
|
requestId, which is the unique identifier for this request. | - (NSInteger) preloadWithSongCode: | (NSInteger) | songCode | |
| jsonOption: | (NSString *_Nullable) | jsonOption | |
Preloads music resources.
You can call this method to preload the music resources you want to play. After this method is called successfully, the SDK triggers the onPreLoadEvent:songCode:percent:lyricUrl:state:reason: callback to report the event of preloading music resources. Before calling this method to preload music resources, you need to call the getMusicCollectionWithMusicChartId:page:pageSize:jsonOption: or searchMusicWithKeyWord:page:pageSize:jsonOption: method to obtain the music resources you want to play. Then, retrieve the music resource ID (songCode) from the onMusicCollectionResult:result:reason: callback triggered by those methods.
AgoraRtcEngineKit object, make sure to wait for the onPreLoadEvent:songCode:percent:lyricUrl:state:reason: callback before calling the destroy method.| songCode | The ID of the music resource, used to identify the music. |
| jsonOption | Extended JSON field. Agora charges based on the application scenario you pass in the sceneType field. Different application scenarios correspond to different rates. Refer to the Billing Instructions for details.
|
| - (NSString *) preloadWithSongCode: | (NSInteger) | songCode |
Preloads a music resource.
You can call this method to preload a music resource that you want to play. After the method is called successfully, the SDK triggers the onPreLoadEvent:songCode:percent:lyricUrl:state:reason: callback to report the preload event of the music resource. Before calling this method to preload a music resource, you need to call either getMusicCollectionWithMusicChartId:page:pageSize:jsonOption: or searchMusicWithKeyWord:page:pageSize:jsonOption: to retrieve the music resource you want to play. Then, obtain the song code (songCode) from the onMusicCollectionResult:result:reason: callback triggered by these methods.
AgoraRtcEngineKit object, you must wait until you receive the onPreLoadEvent:songCode:percent:lyricUrl:state:reason: callback before calling the destroy method.| songCode | The identifier of the music resource. |
requestId, which is the unique identifier of this request. | - (NSInteger) isPreloadedWithSongCode: | (NSInteger) | songCode |
Checks whether a music resource has been preloaded.
This method is a synchronous call. To preload a new music resource, you can call preloadWithSongCode:.
| songCode | The identifier of the music resource used to specify a particular music resource. |
Error Codes for more details and troubleshooting suggestions. | - (NSInteger) removeCacheWithSongCode: | (NSInteger) | songCode |
Deletes a cached music resource.
You can call this method to delete a cached music resource. To delete multiple music resources, you can call this method multiple times.
| songCode | The identifier of the music resource to be deleted. |
Error Codes for details and troubleshooting suggestions. | - (NSArray *) getCaches |
Gets information about the cached music resources.
Before calling this method, you need to allocate sufficient memory to store information about the cached music resources.
If you want to set the number of music resources that can be cached, you can configure it through the config parameter in sharedContentCenterWithConfig:. When you no longer need the cached music resources, you should release the memory in time to prevent memory leaks.
AgoraMusicCacheInfo objects.| - (NSInteger) getInternalSongCode: | (NSInteger) | songCode | |
| jsonOption: | (NSString *_Nullable) | jsonOption | |
Creates an ID for the chorus segment of a music resource.
Applicable scenarios: When you need to play the chorus segment of a music resource, you must call this method to create an ID for the chorus segment of the resource using the jsonOption parameter and the songCode of the music resource. This ID serves as the unique identifier of the resource. After obtaining this ID, you need to pass it as the songCode parameter when calling the corresponding methods to open, preload, or remove the resource.
| songCode | The unique identifier of the music resource. You can obtain it by calling the getMusicCollectionWithMusicChartId:page:pageSize:jsonOption: or searchMusicWithKeyWord:page:pageSize:jsonOption: method, and retrieve the songCode from the onMusicCollectionResult:result:reason: callback. | |||||||||
| jsonOption | Extended JSON field, defaults to nil. The following values are currently supported:
|
Error Codes for details and troubleshooting suggestions. | - (NSString *) getLyricWithSongCode: | (NSInteger) | songCode | |
| lyricType: | (NSInteger) | lyricType | |
Gets the download URL for the lyrics of a music asset.
After this method is successfully called, the SDK triggers the onLyricResult:songCode:lyricUrl:reason: callback to report the download URL of the lyrics.
| songCode | The identifier of the music asset, used to specify the music resource. |
| lyricType | The type of lyrics:
|
requestId, which is the unique identifier for this request. | - (NSString *) getSongSimpleInfoWithSongCode: | (NSInteger) | songCode |
Retrieves detailed information of a specific music resource.
Before calling this method, you need to obtain the identifier of the corresponding music resource. You can retrieve music resources by calling the getMusicCollectionWithMusicChartId:page:pageSize:jsonOption: or searchMusicWithKeyWord:page:pageSize:jsonOption: methods, and obtain the music resource identifier (songCode) through the onMusicCollectionResult:result:reason: callback triggered by those methods. After you call this method, the SDK triggers the onSongSimpleInfoResult:songCode:simpleInfo:reason: callback to report the detailed information of the music resource.
| songCode | The identifier of the music resource, used to specify the music resource. |
requestId, which uniquely identifies this request. | + (void) destroy |
Destroys the AgoraMusicContentCenter instance.
You must call this method before calling the destroy method of AgoraRtcEngineKit.
| - (void) onMusicChartsResult: | (NSString *) | requestId | |
| result: | (NSArray< AgoraMusicChartInfo * > *) | result | |
| errorCode: | (AgoraMusicContentCenterStateReason) | errorCode | |
| - (void) onMusicCollectionResult: | (NSString *) | requestId | |
| result: | (AgoraMusicCollection *) | result | |
| errorCode: | (AgoraMusicContentCenterStateReason) | errorCode | |
| - (void) onLyricResult: | (NSString *) | requestId | |
| songCode: | (NSInteger) | songCode | |
| lyricUrl: | (NSString *_Nullable) | lyricUrl | |
| errorCode: | (AgoraMusicContentCenterStateReason) | errorCode | |
| - (void) onSongSimpleInfoResult: | (NSString *) | requestId | |
| songCode: | (NSInteger) | songCode | |
| simpleInfo: | (NSString *_Nullable) | simpleInfo | |
| errorCode: | (AgoraMusicContentCenterStateReason) | errorCode | |
| - (void) onPreLoadEvent: | (NSString *) | requestId | |
| songCode: | (NSInteger) | songCode | |
| percent: | (NSInteger) | percent | |
| lyricUrl: | (NSString *_Nullable) | lyricUrl | |
| state: | (AgoraMusicContentCenterPreloadState) | state | |
| errorCode: | (AgoraMusicContentCenterStateReason) | errorCode | |