Agora Java API Reference for Android

Public Member Functions | List of all members
io.agora.mediaplayer.IMediaPlayerObserver Interface Reference

## Public Member Functions
void | onPlayerStateChanged (Constants.MediaPlayerState state, Constants.MediaPlayerReason reason)
| Triggered when the player state changes. More...
void | onPositionChanged (long positionMs, long timestampMs)
| Triggered when the player progress changes, once every 1 second. More...
void | onPlayerEvent (Constants.MediaPlayerEvent eventCode, long elapsedTime, String message)
| Reports the playback event. More...
void | onMetaData (Constants.MediaPlayerMetadataType type, byte[] data)
| Triggered when information is obtained.
void | onPlayBufferUpdated (long playCachedBuffer)
| Triggered current playback buffer, once every 1 second. More...
void | onPreloadEvent (String src, Constants.MediaPlayerPreloadEvent event)
| Triggered current playback buffer, once every 1 second. More...
void | onAgoraCDNTokenWillExpire ()
| AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken.
void | onPlayerSrcInfoChanged (SrcInfo from, SrcInfo to)
| Reports current playback source bitrate changed. More...
void | onPlayerInfoUpdated (PlayerUpdatedInfo info)
| Triggered when media player information updated. More...
void | onPlayerCacheStats (CacheStatistics stats)
| Triggered every 1 second, reports the statistics of the files being cached. More...
void | onPlayerPlaybackStats (PlayerPlaybackStats stats)
| Triggered every 1 second, reports the statistics of the media stream being played. More...
void | onAudioVolumeIndication (int volume)
| Triggered every 200 millisecond ,update player current volume range [0,255]. More...

## Member Function Documentation

## ◆ onPlayerStateChanged()

void io.agora.mediaplayer.IMediaPlayerObserver.onPlayerStateChanged | ( | Constants.MediaPlayerState | state,
|  | Constants.MediaPlayerReason | reason
| ) |  |

Triggered when the player state changes.

Parameters

  state | New player state
  reason | Reason for state change

## ◆ onPositionChanged()

void io.agora.mediaplayer.IMediaPlayerObserver.onPositionChanged | ( | long | positionMs,
|  | long | timestampMs
| ) |  |

Triggered when the player progress changes, once every 1 second.

Parameters

  positionMs | Current playback progress, in miliseconds
  timestampMs | Current NTP(Network Time Protocol) time, in miliseconds

## ◆ onPlayerEvent()

void io.agora.mediaplayer.IMediaPlayerObserver.onPlayerEvent | ( | Constants.MediaPlayerEvent | eventCode,
|  | long | elapsedTime,
|  | String | message
| ) |  |

Reports the playback event.

- After calling the `seek` method, the SDK triggers the callback to report the results of the seek operation.
- After calling the `selectAudioTrack` method, the SDK triggers the callback to report that the audio track changes.

Parameters

  eventCode | The playback event. See MEDIA_PLAYER_EVENT.
  elapsedTime | The playback elapsed time.
  message | The playback message.

## ◆ onPlayBufferUpdated()

void io.agora.mediaplayer.IMediaPlayerObserver.onPlayBufferUpdated | ( | long | playCachedBuffer | ) |

Triggered current playback buffer, once every 1 second.

Parameters

  playCachedBuffer | Current playback buffer, in seconds

## ◆ onPreloadEvent()

void io.agora.mediaplayer.IMediaPlayerObserver.onPreloadEvent | ( | String | src,
|  | Constants.MediaPlayerPreloadEvent | event
| ) |  |

Triggered current playback buffer, once every 1 second.

Parameters

  src | Current preload src
  event | Triggered event happened

## ◆ onPlayerSrcInfoChanged()

void io.agora.mediaplayer.IMediaPlayerObserver.onPlayerSrcInfoChanged | ( | SrcInfo | from,
|  | SrcInfo | to
| ) |  |

Reports current playback source bitrate changed.

Reports current playback source info changed.

Parameters

  from | Streaming media information before the change.
  to | Streaming media information after the change.

## ◆ onPlayerInfoUpdated()

void io.agora.mediaplayer.IMediaPlayerObserver.onPlayerInfoUpdated | ( | PlayerUpdatedInfo | info | ) |

Triggered when media player information updated.

Parameters

  info | Include information of media player.

## ◆ onPlayerCacheStats()

void io.agora.mediaplayer.IMediaPlayerObserver.onPlayerCacheStats | ( | CacheStatistics | stats | ) |

Triggered every 1 second, reports the statistics of the files being cached.

Parameters

  stats | Cached file statistics.

## ◆ onPlayerPlaybackStats()

void io.agora.mediaplayer.IMediaPlayerObserver.onPlayerPlaybackStats | ( | PlayerPlaybackStats | stats | ) |

Triggered every 1 second, reports the statistics of the media stream being played.

Parameters

  stats | The statistics of the media stream.

## ◆ onAudioVolumeIndication()

void io.agora.mediaplayer.IMediaPlayerObserver.onAudioVolumeIndication | ( | int | volume | ) |

Triggered every 200 millisecond ,update player current volume range [0,255].

Parameters

  volume | volume of current player.