onReadData

Callback triggered when the SDK reads media resource data.

@CalledByNative int onReadData(ByteBuffer buffer, int bufferSize);

When you call the openWithMediaSource method to open a media resource, the SDK triggers this callback and requests you to provide the buffer for the media resource data.

Parameters

buffer
Data buffer. You need to write bufferSize bytes of data requested by the SDK into this buffer. See ByteBuffer.
bufferSize
Length of the data buffer in bytes.

Return Values

  • When data is read successfully, returns the actual number of bytes read.
  • When data read fails, returns 0.