IMediaPlayerCustomDataProvider

Provides callbacks for opening custom media resource files.

OnReadData

Callback to read media resource data.

public virtual int OnReadData(IntPtr bufferPtr, int bufferSize)
        {
            return 0;
        }

When using OpenWithMediaSource to open a media resource, the SDK triggers this callback to request a buffer containing media resource data from you.

Parameters

bufferPtr
Input parameter. Data buffer in bytes. Write the data of size bufferSize reported by the SDK into this parameter.
bufferSize
Length of the data buffer in bytes.

Return Values

  • If data is read successfully, return the actual number of bytes read.
  • If data reading fails, return 0.

OnSeek

Callback for seeking media resource data.

public virtual Int64 OnSeek(Int64 offset, int whence)
        {
            return 0;
        }

When opening a media resource using OpenWithMediaSource or Open, the SDK triggers this callback to request seeking to a specified position in the media resource.

Parameters

offset
Input parameter. The offset from the origin to seek to, in bytes. Can be positive or negative.
whence
Input parameter. Indicates the origin position for seeking. Possible values:
  • 0: Origin is the beginning of the data. Actual offset is offset.
  • 1: Origin is the current position. Actual offset is current position plus offset.
  • 2: Origin is the end of the data. Actual offset is file length plus offset.
  • 65536: Do not perform seek operation; return file size. Recommended for playing pure audio files such as MP3 or WAV.

Return Values

  • When whence is 65536, returns the media file size.
  • When whence is 0/1/2, returns the actual offset after seeking.
  • -1: Seek failed.