Skip to main content
Version: 3.x

AudioContext

The AudioContext instance can be obtained through Taro.createAudioContext. AudioContext is bound to an audio component with an id, to work with the audio component.

Reference

Methods​

pause​

Pauses the audio playback.

Reference

() => void

API Support​

APIWeChat Mini-ProgramH5React Native
AudioContext.pause✔️

play​

Plays an audio file.

Reference

() => void

API Support​

APIWeChat Mini-ProgramH5React Native
AudioContext.play✔️

seek​

Jumps to the specific position in the audio file.

Reference

(position: number) => void
PropertyTypeDescription
positionnumberThe position where the playback will jump to in the audio file (in sec).

API Support​

APIWeChat Mini-ProgramH5React Native
AudioContext.seek✔️

setSrc​

Sets an audio file address.

Reference

(src: string) => void
PropertyTypeDescription
srcstringAudio file address

API Support​

APIWeChat Mini-ProgramH5React Native
AudioContext.setSrc✔️

API Support​

APIWeChat Mini-ProgramH5React Native
AudioContext.pause✔️
AudioContext.play✔️
AudioContext.seek✔️
AudioContext.setSrc✔️