Agora RTC Objective-C API Reference
Refactor
|
Inherits <NSObject>.
Private Types | |
typedef int(^ | AgoraRtcMediaPlayerCustomSourceOnReadCallback) (id< AgoraRtcMediaPlayerProtocol > _Nonnull playerKit, unsigned char *_Nullable buffer, int bufferLength) |
typedef long long(^ | AgoraRtcMediaPlayerCustomSourceOnSeekCallback) (id< AgoraRtcMediaPlayerProtocol > _Nonnull playerKit, long long offset, int whence) |
|
private |
The player requests to read the data callback, you need to fill the specified length of data into the buffer.
playerKit | the player instance. AgoraRtcMediaPlayerProtocol. |
buffer | the buffer pointer that you need to fill data. |
bufferLength | the bufferSize need to fill of the buffer pointer. |
|
private |
The Player seek event callback, you need to operate the corresponding stream seek operation, You can refer to the definition of lseek() at https://man7.org/linux/man-pages/man2/lseek.2.html.
playerKit | the player instance. AgoraRtcMediaPlayerProtocol. |
offset | the value of seek offset, |
whence | the postion of start seeking, the directive whence as follows: SEEK_SET : The file offset is set to offset bytes. SEEK_CUR : The file offset is set to its current location plus offset bytes. SEEK_END : The file offset is set to the size of the file plus offset bytes. 65536 - AVSEEK_SIZE : Optional. Passing this as the "whence" parameter to a seek function causes it to return the filesize without seeking anywhere. |
- (int) getMediaPlayerId |
Get unique media player id of the media player entity.
- (int) open: | (NSString *) | url | |
startPos: | (NSInteger) | startPos | |
Opens a media file with a specified URL.
url | The URL of the media file that you want to play. |
- (int) openWithAgoraCDNSrc: | (NSString *) | src | |
startPos: | (NSInteger) | startPos | |
Open the Agora CDN media source.
src | The src of the media file that you want to play. |
startPos | The playback position (ms). |
- (int) getAgoraCDNLineCount |
Gets the number of Agora CDN lines.
- (int) switchAgoraCDNLineByIndex: | (int) | index |
Switch Agora CDN lines.
index | Specific line. |
- (int) getCurrentAgoraCDNIndex |
Gets the line of the current CDN.
- (int) enableAutoSwitchAgoraCDN: | (BOOL) | enable |
Enable automatic CDN line switching.
enable | Whether enable. |
- (int) renewAgoraCDNSrcToken: | (NSString *) | token | |
ts: | (NSInteger) | ts | |
Update the CDN source token and timestamp.
token | token. |
ts | ts. |
- (int) switchAgoraCDNSrc: | (NSString *) | src | |
syncPts: | (BOOL) | syncPts | |
Switch the CDN source.
src | Specific line. |
syncPts | Live streaming must be set to false. |
- (int) play |
Plays the media file.
- (int) pause |
Pauses playing the media file.
- (int) stop |
Stops playing the current media file.
- (int) resume |
Resumes playing the media file.
- (int) seekToPosition: | (NSInteger) | position |
Sets the current playback position of the media file.
position | The new playback position (ms). |
- (int) setAudioPitch: | (NSInteger) | pitch |
Sets the pitch of the current media file.
pitch | Sets the pitch of the local music file by chromatic scale. The default value is 0, which means keeping the original pitch. The value ranges from -12 to 12, and the pitch value between consecutive values is a chromatic value. The greater the absolute value of this parameter, the higher or lower the pitch of the local music file. |
- (NSInteger) getDuration |
Gets the duration of the media file.
- (NSInteger) getPosition |
Gets the current playback position of the media file.(ms).
- (NSInteger) getStreamCount |
Gets the number of the media streams in the media resource.
- (AgoraRtcMediaStreamInfo *_Nullable) getStreamByIndex: | (int) | index |
Gets the detailed information of the media stream.
index | The index of the media stream. |
- (int) setLoopCount: | (int) | loopCount |
Sets whether to loop the media file for playback.
loopCount | the number of times looping the media file.
|
- (int) setPlaybackSpeed: | (int) | speed |
Change playback speed
speed | the enum of playback speed |
- (int) selectAudioTrack: | (int) | index |
Slect playback audio track of the media file
index | the index of the audio track in meia file |
- (int) takeScreenshot: | (NSString *) | filename |
take screenshot while playing video
filename | the filename of screenshot file |
- (int) selectInternalSubtitle: | (int) | index |
select internal subtitles in video
index | the index of the internal subtitles |
- (int) setExternalSubtitle: | (NSString *) | url |
set an external subtitle for video
url | The URL of the subtitle file that you want to load. |
- (AgoraMediaPlayerState) getPlayerState |
Gets current playback state.
- (int) mute: | (bool) | isMute |
Turn mute on or off.
isMute | Whether the media source is mute. YES: Yes. NO: No. |
- (BOOL) getMute |
Get mute state.
- (int) adjustPlayoutVolume: | (int) | volume |
Adjust playback volume.
volume | The volume value to be adjusted The volume can be adjusted from 0 to 400: 0: mute; 100: original volume; 400: Up to 4 times the original volume (with built-in overflow protection). |
- (int) getPlayoutVolume |
Get the current playback volume.
- (int) adjustPublishSignalVolume: | (int) | volume |
adjust publish signal volume
- (int) getPublishSignalVolume |
get publish signal volume
- (int) setPlayerOption: | (NSString *) | key | |
value: | (NSInteger) | value | |
modify player option before play,
[in] | key | the option key name reference AgoraConstants.h |
[in] | value | the option value |
- (int) setView: | (View *_Nullable) | view |
Set video rendering view.
- (int) setRenderMode: | (AgoraMediaPlayerRenderMode) | mode |
Set video display mode.
mode | Video display mode |
- (NSString *) getPlaySrc |
Get the current play src.
- (int) switchSrc: | (NSString *) | src | |
syncPts: | (BOOL) | syncPts | |
Switch the media source when open a media through "open" API
src | Specific src. |
syncPts | Live streaming must be set to false. |
- (int) preloadSrc: | (NSString *) | src | |
startPos: | (int) | startPos | |
Preload a media source
src | Specific src. |
startPos | The starting position (ms) for playback. Default value is 0. |
- (int) unloadSrc: | (NSString *) | src |
unload a media source
src | Specific src. |
- (int) playPreloadedSrc: | (NSString *) | src |
Play a pre-loaded media source
src | Specific src. |
- (int) setAudioDualMonoMode: | (AgoraAudioDualMonoMode) | mode |
Set dual-mono output mode of the music file.
mode | The audio dual mono mode. See AgoraAudioDualMonoMode. |
- (int) openWithCustomSourceAtStartPos: | (NSInteger) | startPos | |
withPlayerOnReadData: | (AgoraRtcMediaPlayerCustomSourceOnReadCallback) | onReadDataCallback | |
andPlayerOnSeek: | (AgoraRtcMediaPlayerCustomSourceOnSeekCallback) | onSeekCallback | |
Open media file or stream with custom soucrce. The custom data source provides a data stream input callback, and the player will continue to call back this interface, requesting the user to fill in the data that needs to be played.
startPos | Set the starting position for playback, in seconds. |
onReadDataCallback | The player requests to read the data callback , see AgoraRtcMediaPlayerOnReadCallback |
onSeekCallback | The Player seek event callback, see AgoraRtcMediaPlayerOnSeekCallback |
- (BOOL) setAudioFrameDelegate: | (id< AgoraRtcMediaPlayerAudioFrameDelegate > _Nullable) | delegate |
Registers & unregister the player audio observer
delegate | observer object, pass nil to unregister |
- (BOOL) setVideoFrameDelegate: | (id< AgoraRtcMediaPlayerVideoFrameDelegate > _Nullable) | delegate |
Registers & unregister the player video observer
delegate | observer object, pass nil to unregister. |
- (int) registerMediaPlayerAudioSpectrumDelegate: | (id< AgoraAudioSpectrumDelegate > _Nullable) | delegate | |
intervalInMS: | (NSUInteger) | intervalInMS | |
- (int) unregisterMediaPlayerAudioSpectrumDelegate: | (id< AgoraAudioSpectrumDelegate > _Nullable) | delegate |