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

  playerKit | See `AgoraRtcMediaPlayerProtocol`.
  state | The playback state. See `AgoraMediaPlayerState`.
  reason | The 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

  playerKit | AgoraMediaPlayer
  positionMs | Current playback progress (ms).
  timestampMs | The 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

  playerKit | See `AgoraRtcMediaPlayerProtocol`.
  eventCode | The player event. See `AgoraMediaPlayerEvent`.
  elapsedTime | The time (ms) when the event occurs.
  message | Information 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

  playerKit | See `AgoraRtcMediaPlayerProtocol`.
  data | The detailed data of the media metadata.
  length | The 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

  playerKit | See `AgoraRtcMediaPlayerProtocol`.
  playCachedBuffer | The 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

  playerKit | See `AgoraRtcMediaPlayerProtocol`.
  event | Events 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

  playerKit | See `AgoraRtcMediaPlayerProtocol`.
  to | The media player source information after the change. See `AgoraMediaPlayerSrcInfo`.
  from | The 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

  playerKit | See `AgoraRtcMediaPlayerProtocol`.
  info | Information 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

  info | The statistics of the media file being cached. See `AgoraMediaPlayerCacheStatistics`.
  playerKit | The `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

  info | The statistics of the media file. See `AgoraMediaPlayerPlaybackStats`.
  playerKit | The `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

  volume | The volume of the media player. The value ranges from 0 to 255.
  playerKit | The `AgoraRtcMediaPlayerProtocol` instance.