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)
| Callback for player state changes. More...
void | onPositionChanged (long curr_time, long utc_time)
| Reports the current playback progress of the media resource. More...
void | onResolutionChanged (int width, int height)
| Callback for video resolution change. More...
void | onEvent (int event)
| Player event callback. More...
void | onMetadata (int type, byte[] data)
| Callback for received media auxiliary information. More...
void | onPlayerInfoUpdated (PlayerInfo info)
| Callback triggered when the player and media stream information changes. More...
void | onAudioVolumeIndication (int volume)
| Player volume indication callback. More...

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

Callback for player state changes.

Since
  v4.4.0

If you need to monitor changes in the player state, you must first call `registerObserver` to register the player observer object. Call timing: This callback is triggered by the SDK when the player state changes, reporting the current and previous states.

Parameters

  old_state | The player state before the change. See `PlayerState` for details.
  new_state | The current player state. See `PlayerState` for details. If the current state is `FAILED`, you can get detailed error information through the `error` parameter.
  error | The state or error information. See `Error` for details.

## ◆ onPositionChanged()

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

Reports the current playback progress of the media resource.

Since
  v4.4.0

Call timing: This callback is triggered once every second during the playback of the media resource.

Parameters

  curr_time | The current playback progress in milliseconds.
  utc_time | The current NTP (Network Time Protocol) time in milliseconds.

## ◆ onResolutionChanged()

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

Callback for video resolution change.

Since
  v4.4.0

If you need to monitor changes in the video resolution of the stream played by the player, you must first call `registerObserver` to register a player observer object.
Call timing: This callback is triggered by the SDK when the resolution of the video stream changes, reporting the current width and height of the video.

Parameters

  width | Width of the video frame (px).
  height | Height of the video frame (px).

## ◆ onEvent()

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

Player event callback.

Since
  v4.4.0

If you need to monitor player events, you must first call `registerObserver` to register the player observer object. Call timing: The SDK triggers this callback when a player event changes.

Parameters

  event | Player event. See `PlayerEvent` for details.

## ◆ onMetadata()

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

Callback for received media auxiliary information.

Since
  v4.4.0

If you need to obtain auxiliary information from the media stream, you must first call `registerObserver` to register a player observer object. Call timing: This callback is triggered after the SDK parses the auxiliary information of the media stream being played by the player, reporting the data type and its specific content.

Parameters

  type | Type of auxiliary information: 0: SEI (Supplemental Enhancement Information) type.
  data | Parsed auxiliary information.

## ◆ onPlayerInfoUpdated()

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

Callback triggered when the player and media stream information changes.

Since
  v4.4.0

If you need to obtain information about the player and media stream, you must first call `registerObserver` to register a player observer object. You can also retrieve the information directly using the `getInfo` method. Call timing: This callback is triggered by the SDK when the player and media stream information changes.

Parameters

  info | Information about the player and media stream. See `PlayerInfo` for details.

## ◆ onAudioVolumeIndication()

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

Player volume indication callback.

Since
  v4.4.0

Call timing: The SDK triggers this callback when the player's volume changes.

Parameters

  volume | The current volume of the player, with a value range of [0,225].