IMediaPlayerSourceObserver
Provides callbacks for the media player.
onAudioVolumeIndication
Audio volume indication callback for the media player.
onAudioVolumeIndication?(volume: number): void;
The SDK triggers this callback every 200 ms to report the current volume of the media player.
Parameters
- volume
- The current volume of the player, ranging from [0,255].
onMetaData
Reports received media metadata.
onMetaData?(data: Uint8Array, length: number): void;
After parsing the media metadata, the SDK triggers this callback to report the data type and content of the metadata.
Parameters
- data
- Specific data in a user-defined format.
- length
- Data length in bytes.
onPlayBufferUpdated
Reports the playable duration of the current buffered data.
onPlayBufferUpdated?(playCachedBuffer: number): void;
- When the playable duration of the buffered data is less than the threshold (default is 0),
PlayerEventBufferLow(6) is returned. - When the playable duration is greater than the threshold (default is 0),
PlayerEventBufferRecover(7) is returned.
Parameters
- playCachedBuffer
- The duration (in milliseconds) that the current buffered data can support for playback.
onPlayerCacheStats
Reports information about the currently cached media resources.
onPlayerCacheStats?(stats: CacheStatistics): void;
After calling the openWithMediaSource method and setting the enableCache member to true, the SDK triggers this callback once per second after the media file is opened, reporting statistical data of the currently cached media files.
Parameters
- stats
- Information about the media resources in the cache. See CacheStatistics.
onPlayerEvent
Reports player events.
onPlayerEvent?(
eventCode: MediaPlayerEvent,
elapsedTime: number,
message: string
): void;
- After calling seek to locate playback, the SDK triggers this callback to report the result of the seek operation.
Parameters
- eventCode
- Player event. See MediaPlayerEvent.
- elapsedTime
- Time of the event (in milliseconds).
- message
- Information about the event.
onPlayerInfoUpdated
Callback when media player information changes.
onPlayerInfoUpdated?(info: PlayerUpdatedInfo): void;
When media player-related information changes, the SDK triggers this callback. You can use it for troubleshooting and diagnostics.
Parameters
- info
- Media player-related information. See PlayerUpdatedInfo.
onPlayerPlaybackStats
Reports information about the currently playing media resource.
onPlayerPlaybackStats?(stats: PlayerPlaybackStats): void;
After the media resource starts playing, the SDK triggers this callback once per second to report information about the media resource.
Parameters
- stats
- Information about the media resource. See PlayerPlaybackStats.
onPlayerSourceStateChanged
Reports player state changes.
onPlayerSourceStateChanged?(
state: MediaPlayerState,
reason: MediaPlayerReason
): void;
When the player state changes, the SDK triggers this callback to report the new playback state.
Parameters
- state
- New playback state. See MediaPlayerState.
- reason
- Reason for the player state change. See MediaPlayerReason.
onPlayerSrcInfoChanged
Callback when video bitrate of media resource changes.
onPlayerSrcInfoChanged?(from: SrcInfo, to: SrcInfo): void;
Parameters
onPositionChanged
Reports the playback progress of the current media resource.
onPositionChanged?(positionMs: number): void;
While playing a media file, the SDK automatically triggers this callback every second to report the current playback progress.
Parameters
- positionMs
- Current playback progress in ms.
- timestampMs
- NTP timestamp of the current playback progress in ms.
onPreloadEvent
Reports events during media resource preloading.
onPreloadEvent?(src: string, event: PlayerPreloadEvent): void;
Parameters
- src
- Path of the media resource.
- event
- Event that occurred during media resource preloading. See PlayerPreloadEvent.