Agora Java API Reference for Android

Public Member Functions | List of all members
agora::rtc::IMediaPlayerSourceObserver Class Referenceabstract

`#include <IAgoraMediaPlayerSource.h>`

## Public Member Functions
virtual void | onPlayerSourceStateChanged (media::base::MEDIA_PLAYER_STATE state, media::base::MEDIA_PLAYER_REASON reason)=0
| Reports the playback state change. More...
virtual void | onPositionChanged (int64_t positionMs, int64_t timestampMs)=0
| Reports current playback progress. More...
virtual void | onPlayerEvent (media::base::MEDIA_PLAYER_EVENT eventCode, int64_t elapsedTime, const char *message)=0
| Reports the playback event. More...
virtual void | onMetaData (const void *data, int length)=0
| Occurs when the metadata is received. More...
virtual void | onPlayBufferUpdated (int64_t playCachedBuffer)=0
| Triggered when play buffer updated, once every 1 second. More...
virtual void | onPreloadEvent (const char *src, media::base::PLAYER_PRELOAD_EVENT event)=0
| Triggered when the player preloadSrc. More...
virtual void | onCompleted ()=0
| Occurs when one playback of the media file is completed.
virtual void | onAgoraCDNTokenWillExpire ()=0
| AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken(const char* src).
virtual void | onPlayerSrcInfoChanged (const media::base::SrcInfo &from, const media::base::SrcInfo &to)=0
| Reports current playback source bitrate changed. More...
virtual void | onPlayerInfoUpdated (const media::base::PlayerUpdatedInfo &info)=0
| Triggered when media player information updated. More...
virtual void | onPlayerCacheStats (const media::base::CacheStatistics &stats)
| Triggered every 1 second, reports the statistics of the files being cached. More...
virtual void | onPlayerPlaybackStats (const media::base::PlayerPlaybackStats &stats)
| Triggered every 1 second, reports the statistics of the media stream being played. More...
virtual void | onAudioVolumeIndication (int volume)=0
| Triggered every 200 millisecond ,update player current volume range [0,255]. More...

## Detailed Description

This class class reports runtime events to the applications.

## Member Function Documentation

## ◆ onPlayerSourceStateChanged()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPlayerSourceStateChanged | ( | media::base::MEDIA_PLAYER_STATE | state,
|  | media::base::MEDIA_PLAYER_REASON | reason
| ) |  |
| pure virtual

Reports the playback state change.

When the state of the playback changes, the SDK triggers this callback to report the new playback state and the reason or error for the change.

Parameters

  state | The new playback state after change. See MEDIA_PLAYER_STATE.
  reason | The player's error code. See MEDIA_PLAYER_REASON.

## ◆ onPositionChanged()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPositionChanged | ( | int64_t | positionMs,
|  | int64_t | timestampMs
| ) |  |
| pure virtual

Reports current playback progress.

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

Parameters

  positionMs | Current playback progress (milisecond).
  timestampMs | Current NTP(Network Time Protocol) time (milisecond).

## ◆ onPlayerEvent()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPlayerEvent | ( | media::base::MEDIA_PLAYER_EVENT | eventCode,
|  | int64_t | elapsedTime,
|  | const char * | message
| ) |  |
| pure virtual

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.

## ◆ onMetaData()

virtual void agora::rtc::IMediaPlayerSourceObserver::onMetaData | ( | const void * | data,
|  | int | length
| ) |  |
| pure virtual

Occurs when the metadata is received.

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

Parameters

  data | The detailed data of the media metadata.
  length | The data length (bytes).

## ◆ onPlayBufferUpdated()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPlayBufferUpdated | ( | int64_t | playCachedBuffer | ) |
| pure virtual

Triggered when play buffer updated, once every 1 second.

Parameters

  int | cached buffer during playing, in milliseconds

## ◆ onPreloadEvent()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPreloadEvent | ( | const char * | src,
|  | media::base::PLAYER_PRELOAD_EVENT | event
| ) |  |
| pure virtual

Triggered when the player preloadSrc.

Parameters

  event |

## ◆ onPlayerSrcInfoChanged()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPlayerSrcInfoChanged | ( | const media::base::SrcInfo & | from,
|  | const media::base::SrcInfo & | to
| ) |  |
| pure virtual

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()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPlayerInfoUpdated | ( | const media::base::PlayerUpdatedInfo & | info | ) |
| pure virtual

Triggered when media player information updated.

Parameters

  info | Include information of media player.

## ◆ onPlayerCacheStats()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPlayerCacheStats | ( | const media::base::CacheStatistics & | stats | ) |
| virtual

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

Parameters

  stats | Cached file statistics.

## ◆ onPlayerPlaybackStats()

virtual void agora::rtc::IMediaPlayerSourceObserver::onPlayerPlaybackStats | ( | const media::base::PlayerPlaybackStats & | stats | ) |
| virtual

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

Parameters

  stats | The statistics of the media stream.

## ◆ onAudioVolumeIndication()

virtual void agora::rtc::IMediaPlayerSourceObserver::onAudioVolumeIndication | ( | int | volume | ) |
| pure virtual

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

Parameters

  volume | volume of current player.