Agora Java API Reference for Android

Public Member Functions | Protected Member Functions | List of all members
io.agora.rte.PlayerObserver Class Reference

## Public Member Functions
long | getNativeHandle ()
void | onStateChanged (int old_state, int new_state, Error error)
void | onPositionChanged (long curr_time, long utc_time)
| Reports current playback progress.This callback will be triggered when the playback position changed. More...
void | onResolutionChanged (int width, int height)
void | onEvent (int event)
void | onMetadata (int type, byte[] data)
void | onPlayerInfoUpdated (PlayerInfo info)
void | onAudioVolumeIndication (int volume)

## Protected Member Functions
void | finalize ()

## Detailed Description

Player Observer, an interface for receiving player event callbacks.

Since
  v4.4.0

## Member Function Documentation

## ◆ onStateChanged()

void io.agora.rte.PlayerObserver.onStateChanged | ( | int | old_state,
|  | int | new_state,
|  | Error | error
| ) |  |

Player state callback. This function is called when the player state changes.

Since
  v4.4.0

Parameters

  old_state | The previous state.
  new_state | The new state.
  error | Possible ErrorCode returns. Only when the new_state value corresponds to Constants.PlayerState.FAILED, you need to check the value of this parameter. ErrorCode.DEFAULT. For specific reasons, see Error.Message, including the following situations: Failed to connect to the channel. ErrorCode.INVALID_ARGUMENT. Invalid appid. Invalid channelid. Invalid uid. ErrorCode.AUTHENTICATION_FAILED. Invalid token. Token expired. ErrorCode.STREAM_NOT_FOUND. After entering the channel, no stream was received from the broadcaster. for more than 10 seconds.

Returns
  void

## ◆ onPositionChanged()

void io.agora.rte.PlayerObserver.onPositionChanged | ( | long | curr_time,
|  | long | utc_time
| ) |  |

Reports current playback progress.This callback will be triggered when the playback position changed.

Since
  v4.4.0

Parameters

  curr_time | Current playback progress (milisecond).
  utc_time | Current NTP(Network Time Protocol) time (milisecond).

Returns
  void

## ◆ onResolutionChanged()

void io.agora.rte.PlayerObserver.onResolutionChanged | ( | int | width,
|  | int | height
| ) |  |

Video resolution change callback.

Since
  v4.4.0

Parameters

  width | The width of the video frame.
  height | The height of the video frame.

Returns
  void

## ◆ onEvent()

void io.agora.rte.PlayerObserver.onEvent | ( | int | event | ) |

Event callback.

Since
  v4.4.0

Parameters

  event | The event notified by the callback. Refer to Constants.PlayerEvent type. Currently, the following events can be handled accordingly: Constants.PlayerEvent.FREEZE_START: Indicates that stuttering has occurred or shows a loading animation. Constants.PlayerEvent.FREEZE_STOP: Indicates that stuttering has ended or stops the loading animation. Constants.PlayerEvent.AUTHENTICATION_WILL_EXPIRE: Regenerate the token, use the new token to construct the rte URL, and call Player.openWithUrl to refresh the token. Constants.PlayerEvent.ABR_FALLBACK_TO_AUDIO_ONLY_LAYER: Indicates that due to network reasons, it has fallen back to audio-only mode. Constants.PlayerEvent.ABR_RECOVER_FROM_AUDIO_ONLY_LAYER: Indicates that it has recovered from audio-only mode to video mode.

Returns
  void

## ◆ onMetadata()

void io.agora.rte.PlayerObserver.onMetadata | ( | int | type,
|  | byte[] | data
| ) |  |

Metadata callback.

Since
  v4.4.0

Parameters

  type | The type of metadata.
  data | The metadata buffer.

Returns
  void

## ◆ onPlayerInfoUpdated()

void io.agora.rte.PlayerObserver.onPlayerInfoUpdated | ( | PlayerInfo | info | ) |

Player information update callback. This is called when fields in PlayerInfo are updated.

Since
  v4.4.0

Parameters

  info | The current PlayerInfo information.

Returns
  void

## ◆ onAudioVolumeIndication()

void io.agora.rte.PlayerObserver.onAudioVolumeIndication | ( | int | volume | ) |

Broadcaster audio volume update callback.

Since
  v4.4.0

Parameters

  volume | The current volume of the player. The value range is [0, 255].

Returns
  void