IMediaPlayerSourceObserver
Provides callbacks for the media player.
onAudioVolumeIndication
Audio volume indication callback from 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 retrieved 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
- The actual data in a user-defined format.
- length
- The length of the data in bytes.
onPlayBufferUpdated
Reports the playable duration of the current buffer.
onPlayBufferUpdated?(playCachedBuffer: number): void;
- If the buffered duration is less than the threshold (default is 0), it returns
PlayerEventBufferLow(6). - If the buffered duration is greater than the threshold (default is 0), it returns
PlayerEventBufferRecover(7).
Parameters
- playCachedBuffer
- The duration (ms) that the current buffered data can support for playback.
onPlayerCacheStats
Reports information about the media resources currently in cache.
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 to report statistics of the cached media files.
Parameters
- stats
- Information about the media resources in cache. See CacheStatistics.
onPlayerEvent
Reports events from the media player.
onPlayerEvent?(
eventCode: MediaPlayerEvent,
elapsedTime: number,
message: string
): void;
- After calling seek to seek playback, the SDK triggers this callback to report the result of the seek operation.
Parameters
- eventCode
- Media player event. See MediaPlayerEvent.
- elapsedTime
- The time (ms) when the event occurred.
- message
- Information about the event.
onPlayerInfoUpdated
Callback when media player-related 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 changes in the player state.
onPlayerSourceStateChanged?(
state: MediaPlayerState,
reason: MediaPlayerReason
): void;
When the player state changes, the SDK triggers this callback to report the new playback state.
Parameters
- state
- The new playback state. See MediaPlayerState.
- reason
- The reason for the player state change. See MediaPlayerReason.
onPlayerSrcInfoChanged
Callback for video bitrate change of media resource.
onPlayerSrcInfoChanged?(from: SrcInfo, to: SrcInfo): void;
Parameters
onPositionChanged
Reports the current playback progress of the media resource.
onPositionChanged?(positionMs: number): void;
When playing a media file, the SDK automatically triggers this callback every second to report the current playback progress.
Parameters
- positionMs
- The current playback progress in ms.
- timestampMs
- The NTP timestamp of the current playback progress in ms.
onPreloadEvent
Reports events related to preloading media resources.
onPreloadEvent?(src: string, event: PlayerPreloadEvent): void;
Parameters
- src
- The path of the media resource.
- event
- The event that occurs during media resource preloading. See PlayerPreloadEvent.