MediaPlayerSourceObserver
Provides callbacks for media players.
onAudioVolumeIndication
Reports the volume of the media player.
final void Function(int volume)? onAudioVolumeIndication;
The SDK triggers this callback every 200 milliseconds to report the current volume of the media player.
Parameters
- volume
- The volume of the media player. The value ranges from 0 to 255.
onMetaData
Occurs when the media metadata is received.
final void Function(Uint8List data, int length)? onMetaData;
The callback occurs when the player receives the media metadata and reports the detailed information of the media metadata.
Parameters
- data
- The detailed data of the media metadata.
- length
- The data length (bytes).
onPlayBufferUpdated
Reports the playback duration that the buffered data can support.
final void Function(int playCachedBuffer)? onPlayBufferUpdated;
- When the playback duration supported by the buffered data is less than the threshold (0 by default), the SDK returns playerEventBufferLow.
- When the playback duration supported by the buffered data is greater than the threshold (0 by default), the SDK returns playerEventBufferRecover.
Parameters
- playCachedBuffer
- The playback duration (ms) that the buffered data can support.
onPlayerCacheStats
Reports the statistics of the media file being cached.
final void Function(CacheStatistics stats)? onPlayerCacheStats;
Details
After you call the openWithMediaSource method and set enableCache as true
, the SDK triggers this callback once per second to report the statistics of the media file being cached.
Parameters
- stats
- The statistics of the media file being cached. See CacheStatistics.
onPlayerEvent
Reports the player events.
final void Function( MediaPlayerEvent eventCode, int elapsedTime, String message)? onPlayerEvent;
- After calling the seek method, the SDK triggers the callback to report the results of the seek operation.
Parameters
- eventCode
- The player events. See MediaPlayerEvent.
- elapsedTime
- The time (ms) when the event occurs.
- message
- Information about the event.
onPlayerInfoUpdated
Occurs when information related to the media player changes.
final void Function(PlayerUpdatedInfo info)? onPlayerInfoUpdated;
When the information about the media player changes, the SDK triggers this callback. You can use this callback for troubleshooting.
Parameters
- info
- Information related to the media player. See PlayerUpdatedInfo.
onPlayerPlaybackStats
The statistics of the media file being played.
final void Function(PlayerPlaybackStats stats)? onPlayerPlaybackStats;
Details
The SDK triggers this callback once per second to report the statistics of the media file being played.
Parameters
- stats
- The statistics of the media file. See PlayerPlaybackStats.
onPlayerSourceStateChanged
Reports the changes of playback state.
final void Function(MediaPlayerState state, MediaPlayerReason reason)? onPlayerSourceStateChanged;
When the state of the media player changes, the SDK triggers this callback to report the current playback state.
Parameters
- state
- The playback state. See MediaPlayerState.
- reason
- The reason for the changes in the media player status. See MediaPlayerReason.
onPlayerSrcInfoChanged
Occurs when the video bitrate of the media resource changes.
final void Function(SrcInfo from, SrcInfo to)? onPlayerSrcInfoChanged;
Parameters
onPositionChanged
Reports the playback progress of the media file.
final void Function(int position)? onPositionChanged;
When playing media files, the SDK triggers this callback every two second to report current playback progress.
Parameters
- positionMs
- The playback position (ms) of media files.
- timeStampMs
- The NTP timestamp (ms) of the current playback progress.
onPreloadEvent
Reports the events of preloaded media resources.
final void Function(String src, PlayerPreloadEvent event)? onPreloadEvent;
Parameters
- src
- The URL of the media resource.
- event
- Events that occur when media resources are preloaded. See PlayerPreloadEvent.