onSeek
Callback triggered when the SDK seeks media resource data.
long onSeek(long offset, int whence)
When you call the openWithMediaSource or open method to open a custom media resource, the SDK triggers this callback and requests data at a specific position in the media resource.
Parameters
- offset
- Offset from the starting point to the target position, in bytes. This value can be positive or negative.
- whence
- Starting point. Can be set to one of the following values:
- 0: Start from the beginning of the data. The actual data offset after seeking is
offset. - 1: Start from the current position. The actual data offset after seeking is current position plus
offset. - 2: Start from the end of the data. The actual data offset after seeking is total data length plus
offset. - 65536: Do not perform seek. Returns the file size. Recommended for pure audio files such as MP3, WAV.
- 0: Start from the beginning of the data. The actual data offset after seeking is
Return Values
- When
whenceis 65536, returns the media file size. - When
whenceis 0, 1, or 2, returns the actual data offset after seeking. - -1: Seek failed.