Agora RTC Objective-C API Reference  Refactor
Instance Methods
<AgoraRtcMediaPlayerDelegate> Protocol Reference

Inherits <NSObject>.

Instance Methods

(void) - AgoraRtcMediaPlayer:didChangedToState:reason:
 
(void) - AgoraRtcMediaPlayer:didChangedToPosition:atTimestamp:
 
(void) - AgoraRtcMediaPlayer:didOccurEvent:elapsedTime:message:
 
(void) - AgoraRtcMediaPlayer:didReceiveData:length:
 
(void) - AgoraRtcMediaPlayer:didPlayBufferUpdated:
 
(void) - AgoraRtcMediaPlayer:didPreloadEvent:
 
(void) - AgoraRtcMediaPlayer:playerSrcInfoDidChange:from:
 
(void) - AgoraRtcMediaPlayer:infoUpdated:
 
(void) - AgoraRtcMediaPlayer:cacheStats:
 
(void) - AgoraRtcMediaPlayer:playbackStats:
 
(void) - onAgoraCDNTokenWillExpire
 
(void) - AgoraRtcMediaPlayer:volumeIndicationDidReceive:
 

Method Documentation

◆ AgoraRtcMediaPlayer:didChangedToState:reason:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
didChangedToState: (AgoraMediaPlayerState state
reason: (AgoraMediaPlayerReason reason 
optional

Reports the changes of playback state.

When the state of the media player changes, the SDK triggers this callback to report the current playback state.

Parameters
playerKitSee AgoraRtcMediaPlayerProtocol.
stateThe playback state. See AgoraMediaPlayerState.
reasonThe reason for the changes in the media player status. See AgoraMediaPlayerReason.

◆ AgoraRtcMediaPlayer:didChangedToPosition:atTimestamp:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
didChangedToPosition: (NSInteger)  positionMs
atTimestamp: (NSTimeInterval)  timestampMs 
optional

Reports current playback progress.

The callback occurs once every one second during the playback and reports current playback progress.

Parameters
playerKitAgoraMediaPlayer
positionMsCurrent playback progress (ms).
timestampMsThe NTP timestamp (ms) when the position is sent.

◆ AgoraRtcMediaPlayer:didOccurEvent:elapsedTime:message:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
didOccurEvent: (AgoraMediaPlayerEvent eventCode
elapsedTime: (NSInteger)  elapsedTime
message: (NSString *_Nullable)  message 
optional

Reports the player events.

  • After calling the seekToPosition: method, the SDK triggers the callback to report the results of the seek operation.
Parameters
playerKitSee AgoraRtcMediaPlayerProtocol.
eventCodeThe player event. See AgoraMediaPlayerEvent.
elapsedTimeThe time (ms) when the event occurs.
messageInformation about the event.

◆ AgoraRtcMediaPlayer:didReceiveData:length:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
didReceiveData: (NSString *_Nullable)  data
length: (NSInteger)  length 
optional

Occurs when the media metadata is received.

The callback occurs when the player receives the media metadata and reports the detailed information of the media metadata.

Parameters
playerKitSee AgoraRtcMediaPlayerProtocol.
dataThe detailed data of the media metadata.
lengthThe data length (bytes).

◆ AgoraRtcMediaPlayer:didPlayBufferUpdated:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
didPlayBufferUpdated: (NSInteger)  playCachedBuffer 
optional

Reports the playback duration that the buffered data can support.

When playing online media resources, the SDK triggers this callback every two seconds to report the playback duration that the currently buffered data can support.

  • When the playback duration supported by the buffered data is less than the threshold (0 by default), the SDK returns AgoraMediaPlayerEventBufferLow (6).
  • When the playback duration supported by the buffered data is greater than the threshold (0 by default), the SDK returns AgoraMediaPlayerEventBufferRecover (7).
Parameters
playerKitSee AgoraRtcMediaPlayerProtocol.
playCachedBufferThe playback duration (ms) that the buffered data can support.

◆ AgoraRtcMediaPlayer:didPreloadEvent:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
didPreloadEvent: (AgoraMediaPlayerPreloadEvent event 
optional

Reports the events of preloaded media resources.

Parameters
playerKitSee AgoraRtcMediaPlayerProtocol.
eventEvents that occur when media resources are preloaded. See AgoraMediaPlayerPreloadEvent.

◆ AgoraRtcMediaPlayer:playerSrcInfoDidChange:from:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
playerSrcInfoDidChange: (AgoraMediaPlayerSrcInfo *_Nonnull)  to
from: (AgoraMediaPlayerSrcInfo *_Nonnull)  from 
optional

Reports the playback progress of the media file.

When playing media files, the SDK triggers this callback every two second to report current playback progress.

Parameters
playerKitSee AgoraRtcMediaPlayerProtocol.
toThe media player source information after the change. See AgoraMediaPlayerSrcInfo.
fromThe media player source information before the change. See AgoraMediaPlayerSrcInfo.

◆ AgoraRtcMediaPlayer:infoUpdated:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
infoUpdated: (AgoraMediaPlayerUpdatedInfo *_Nonnull)  info 
optional

Occurs when information related to the media player changes.

When the information about the media player changes, the SDK triggers this callback. You can use this callback for troubleshooting.

Parameters
playerKitSee AgoraRtcMediaPlayerProtocol.
infoInformation related to the media player. See AgoraMediaPlayerUpdatedInfo.

◆ AgoraRtcMediaPlayer:cacheStats:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
cacheStats: (AgoraMediaPlayerCacheStatistics *_Nonnull)  info 
optional

Reports the statistics of the media file being cached.

After you call the openWithMediaSource: method and set enableCache as YES, the SDK triggers this callback once per second to report the statistics of the media file being cached.

Parameters
infoThe statistics of the media file being cached. See AgoraMediaPlayerCacheStatistics.
playerKitThe AgoraRtcMediaPlayerProtocol instance.

◆ AgoraRtcMediaPlayer:playbackStats:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
playbackStats: (AgoraMediaPlayerPlaybackStats *_Nonnull)  info 
optional

Reports the statistics of the media file being played.

The SDK triggers this callback once per second to report the statistics of the media file being played.

Parameters
infoThe statistics of the media file. See AgoraMediaPlayerPlaybackStats.
playerKitThe AgoraRtcMediaPlayerProtocol instance.

◆ onAgoraCDNTokenWillExpire

- (void) onAgoraCDNTokenWillExpire
optional

AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken(const char* src).

Deprecated:
4.6.0

◆ AgoraRtcMediaPlayer:volumeIndicationDidReceive:

- (void) AgoraRtcMediaPlayer: (id< AgoraRtcMediaPlayerProtocol > _Nonnull)  playerKit
volumeIndicationDidReceive: (NSInteger)  volume 
optional

Reports the volume of the media player.

The SDK triggers this callback every 200 milliseconds to report the current volume of the media player.

Parameters
volumeThe volume of the media player. The value ranges from 0 to 255.
playerKitThe AgoraRtcMediaPlayerProtocol instance.