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)
 Reports the changes of playback state. More...
 
void onPositionChanged (long positionMs, long timestampMs)
 Reports the playback progress of the media file. More...
 
void onPlayerEvent (Constants.MediaPlayerEvent eventCode, long elapsedTime, String message)
 Reports the player events. More...
 
void onMetaData (Constants.MediaPlayerMetadataType type, byte[] data)
 Occurs when the media metadata is received. More...
 
void onPlayBufferUpdated (long playCachedBuffer)
 Reports the playback duration that the buffered data can support. More...
 
void onPreloadEvent (String src, Constants.MediaPlayerPreloadEvent event)
 Reports the events of preloaded media resources. More...
 
void onAgoraCDNTokenWillExpire ()
 AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken. More...
 
void onPlayerSrcInfoChanged (SrcInfo from, SrcInfo to)
 Occurs when the video bitrate of the media resource changes. More...
 
void onPlayerInfoUpdated (PlayerUpdatedInfo info)
 Occurs when information related to the media player changes. More...
 
void onPlayerCacheStats (CacheStatistics stats)
 Reports the statistics of the media file being cached. More...
 
void onPlayerPlaybackStats (PlayerPlaybackStats stats)
 Reports the statistics of the media file being played. More...
 
void onAudioVolumeIndication (int volume)
 Reports the volume of the media player. More...
 

Member Function Documentation

◆ onPlayerStateChanged()

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

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
stateThe playback state. See MediaPlayerState.
reasonThe reason for the changes in the media player status. See MediaPlayerReason.

◆ onPositionChanged()

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

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
positionMsThe playback position (ms) of media files.
timeStampMsThe NTP timestamp (ms) of the current playback progress.

◆ onPlayerEvent()

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

Reports the player events.

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

◆ onMetaData()

void io.agora.mediaplayer.IMediaPlayerObserver.onMetaData ( Constants.MediaPlayerMetadataType  type,
byte[]  data 
)

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
typeThe type of media metadata. See MediaPlayerMetadataType.
dataThe detailed data of the media metadata.

◆ onPlayBufferUpdated()

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

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 PLAYER_EVENT_BUFFER_LOW (6).
  • When the playback duration supported by the buffered data is greater than the threshold (0 by default), the SDK returns PLAYER_EVENT_BUFFER_RECOVER (7).
Parameters
playCachedBufferThe playback duration (ms) that the buffered data can support.

◆ onPreloadEvent()

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

Reports the events of preloaded media resources.

Parameters
srcThe URL of the media resource.
eventEvents that occur when media resources are preloaded. See MediaPlayerPreloadEvent.

◆ onAgoraCDNTokenWillExpire()

void io.agora.mediaplayer.IMediaPlayerObserver.onAgoraCDNTokenWillExpire ( )

AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken.

Deprecated:
4.6.0

◆ onPlayerSrcInfoChanged()

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

Occurs when the video bitrate of the media resource changes.

Parameters
fromInformation about the video bitrate of the media resource being played. See SrcInfo.
toInformation about the changed video bitrate of media resource being played. See SrcInfo.

◆ onPlayerInfoUpdated()

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

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
infoInformation related to the media player. See PlayerUpdatedInfo.

◆ onPlayerCacheStats()

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

Reports the statistics of the media file being cached.

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

Parameters
statsThe statistics of the media file being cached. See CacheStatistics.

◆ onPlayerPlaybackStats()

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

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
statsThe statistics of the media file. See PlayerPlaybackStats.

◆ onAudioVolumeIndication()

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

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.