PlayerObserver

The interface class which provides callbacks for the player.

onAudioVolumeIndication

Reports the volume indication of the broadcaster.

public void onAudioVolumeIndication(int volume){}
Since
v4.5.0

Trigger timing

The SDK triggers this callback when the volumn of the broadcaster changes.

Restrictions

None.

Parameters

volume
The current volumn of the broadcaster. The value range is [0,225].

onEvent

The player event callback.

public void onEvent(int event){}
Since
v4.5.0

To monitor player events, you need to call registerObserver to register a player observer object.

Trigger timing

The SDK triggers this callback when the player event changes.

Restrictions

None.

Parameters

event
The player event. See PlayerEvent.

onMetadata [2/2]

Occurs when the metadata is received.

public void onMetadata(int type, byte[] data){}
Since
v4.5.0

To receive the metadata of the media stream, call registerObserver to register a player observer object first.

Trigger timing

After the SDK parses the metadata of the media stream being played, it triggers this callback to report the data type and its content.

Restrictions

None.

Parameters

type
The metadata type.
  • 1: The type is SEI.
data
The metadata.

onPlayerInfoUpdated [2/2]

Occurs when the information of the player and the media stream changes.

public void onPlayerInfoUpdated(PlayerInfo info){}
Since
v4.5.0

To receive the information of the player and the media stream, call registerObserver to register a player observer object first. You can also get the infomation by calling getInfo.

Trigger timing

The SDK triggers this callback when the information of the player and the media stream changes.

Restrictions

None.

Parameters

info
The information of the player and the media stream. See PlayerInfo.

onResolutionChanged

Occurs when video resolution changes.

public void onResolutionChanged(int width, int height){}
Since
v4.5.0

To monitor the resolution changes of the video stream being played, ensure that you call registerObserver to register the player observer first.

Trigger timing

When the resolution of the video stream changes, the SDK triggers this callback to report the current width and height of the video.

Restrictions

None.

Parameters

width
The width (px) of the video frame.
height
The height (px) of the video frame.

onStateChanged

Occurs when the player state changes.

public void onStateChanged(int old_state, int new_state, Error error){}
Since
v4.5.0

To monitor player events, you need to call registerObserver to register a player observer object.

Trigger timing

When the player state changes, the SDK triggers this callback the report the previous and current states.

Restrictions

None.

Parameters

old_state
The previous player state. See PlayerState.
new_state
The current player state. See PlayerState. If the current state is FAILED, you can get the detailed error information from the error parameter.
error
The state or error information: Error.