IMediaPlayerSourceObserver

Provides callbacks for the media player.

onAudioVolumeIndication

Callback for media player volume indication.

public virtual void OnAudioVolumeIndication(int volume) {}

The SDK triggers this callback every 200 milliseconds to report the current volume of the media player.

Parameters

volume
Current volume of the player, range: [0,255].

OnMetaData

Reports acquired media metadata.

public virtual void OnMetaData(byte[] data, int length) { }

After parsing the media metadata, the SDK triggers this callback to report the data type and actual data of the metadata.

Parameters

data
Actual data in a user-defined format.
length
Length of the data in bytes.

OnPlayBufferUpdated

Reports the duration the current buffered data can support playback.

public virtual void OnPlayBufferUpdated(Int64 playCachedBuffer) { }
During online media playback, the SDK triggers this callback every second to report the playback duration supported by the current buffered data.
  • When the buffered playback duration is less than the threshold (default is 0), PLAYER_EVENT_BUFFER_LOW (6) is returned.
  • When the buffered playback duration exceeds the threshold (default is 0), PLAYER_EVENT_BUFFER_RECOVER (7) is returned.

Parameters

playCachedBuffer
Playback duration supported by the current buffered data (milliseconds).

OnPlayerCacheStats

Reports information about the media resources currently in cache.

public virtual void OnPlayerCacheStats(CacheStatistics stats)
                {
                }

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 about the currently cached media files.

Parameters

stats
Information about the media resources in the cache. See CacheStatistics.

OnPlayerEvent

Reports player events.

public virtual void OnPlayerEvent(MEDIA_PLAYER_EVENT eventCode, Int64 elapsedTime, string message) { }
  • After calling Seek to seek playback, the SDK triggers this callback to report the result of the seek operation.

Parameters

eventCode
Player event. See MEDIA_PLAYER_EVENT.
elapsedTime
Time when the event occurred (milliseconds).
message
Information about the event.

OnPlayerInfoUpdated

Callback when media player related information changes.

public virtual void OnPlayerInfoUpdated(PlayerUpdatedInfo info) { }

This callback is triggered by the SDK when media player related information changes. 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.

public virtual void OnPlayerPlaybackStats(PlayerPlaybackStats stats)
                {
                }

After the media resource starts playing, the SDK triggers this callback every second to report related information about the media resource.

Parameters

stats
Information about the media resource. See PlayerPlaybackStats.

OnPlayerSourceStateChanged

Reports changes in player state.

public virtual void OnPlayerSourceStateChanged(MEDIA_PLAYER_STATE state, MEDIA_PLAYER_REASON reason)

This callback is triggered by the SDK when the player state changes, reporting the new playback state.

Parameters

state
The new playback state. See MEDIA_PLAYER_STATE.
reason
The reason for the player state change. See MEDIA_PLAYER_REASON.

OnPlayerSrcInfoChanged

Callback for video bitrate changes in media resource.

public virtual void OnPlayerSrcInfoChanged(SrcInfo from, SrcInfo to) {}

Parameters

from
Information about the video bitrate before the change during media playback. See SrcInfo.
to
Information about the video bitrate after the change during media playback. See SrcInfo.

OnPositionChanged

Reports the current playback progress of the media resource.

public virtual void OnPositionChanged(Int64 position_ms) { }

While playing a media file, the SDK automatically triggers this callback every second to report the current playback progress.

Parameters

position_ms
Current playback progress in milliseconds.
timestampMs
NTP timestamp of the current playback progress in milliseconds.

OnPreloadEvent

Reports events related to preloading media resources.

public virtual void OnPreloadEvent(string src, PLAYER_PRELOAD_EVENT @event) { }

Parameters

src
Path to the media resource.
@event
Event that occurred during media resource preloading. See PLAYER_PRELOAD_EVENT.