|
Agora RTC Objective-C API Reference
Refactor
|
Inherits <NSObjectAgoraRtcMediaPlayerProtocol>.
Instance Methods | |
| (NSInteger) | - openMediaWithSongCode:startPos: |
| (NSInteger) | - setPlayMode: |
| - (NSInteger) openMediaWithSongCode: | (NSInteger) | songCode | |
| startPos: | (NSInteger) | startPos | |
Opens a music resource by its resource ID.
Before calling this method, make sure the music resource you want to play has been fully loaded. You can check whether the music resource has been preloaded by calling the isPreloadedWithSongCode: method, or by listening to the onPreLoadEvent:songCode:percent:lyricUrl:state:reason: callback.
After calling this method, the AgoraRtcMediaPlayer:didChangedToState:reason: callback is triggered. Once you receive the playback state AgoraMediaPlayerStateOpenCompleted, you can call the play method to start playback.
open:startPos: method under the AgoraRtcMediaPlayerProtocol class.| songCode | The ID of the music resource, used to identify the music content. |
| startPos | The starting playback position in milliseconds. The default value is 0. |
Error Codes for details and recommended solutions. | - (NSInteger) setPlayMode: | (AgoraMusicPlayMode) | mode |
Sets the playback mode for a music resource.
You can call this method to enable the original vocals, accompaniment, or vocal guide. If you do not call this method, accompaniment is played by default. If the music resource does not contain accompaniment, the original vocals are played. Applicable scenarios: In entertainment scenarios such as online karaoke or live shows, if you need to play copyrighted music provided by the Agora Content Center, you can call this method to set the playback mode. Call timing: You must call this method after createMusicPlayerWithDelegate:.
onMusicCollectionResult:result:reason: callback. From the result parameter, you can learn which playback modes are supported for the copyrighted music.| mode | The playback mode. See AgoraMusicPlayMode for details. |
Error Codes for details and troubleshooting.