InnerAudioContext.seek

The InnerAudioContext.seek method allows mini program developers to jump to a specific position in the audio playback.

Parameters

Parameter

Type

Required

Description

position

Number

Yes

The target playback position in seconds from the start of the audio track. The value supports up to 3 decimal places, allowing for millisecond precision. This value must be between 0 and the audio length.

Return value

Parameter

Type

Required

Description

error

Number

No

An error code that represents the specific error encountered. This parameter is specified if an error occurs when executing the method. For more information, refer to Error codes.

errorMessage

String

No

An error message that describes the corresponding error code. This parameter is specified if error is specified. For more information, refer to Error codes.

Error codes

Error code

Error message

Further action

2

Invalid parameters

Refer to the Parameters table to ensure that all parameters are specified correctly, and that all required parameters are provided.

Sample code

copy
this.innerAudioContext = my.createInnerAudioContext();

this.innerAudioContext.src = 'https://www.sample.com/sample.mp3';
// Set the target playback position, e.g., 20s
this.innerAudioContext.seek(20);