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.
Methods
pause
Pauses the audio playback.
() => void
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| AudioContext.pause | ✔️ |
play
Plays an audio file.
() => void
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| AudioContext.play | ✔️ |
seek
Jumps to the specific position in the audio file.
(position: number) => void
| Property | Type | Description |
|---|---|---|
| position | number | The position where the playback will jump to in the audio file (in sec). |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| AudioContext.seek | ✔️ |
setSrc
Sets an audio file address.
(src: string) => void
| Property | Type | Description |
|---|---|---|
| src | string | Audio file address |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| AudioContext.setSrc | ✔️ |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| AudioContext.pause | ✔️ | ||
| AudioContext.play | ✔️ | ||
| AudioContext.seek | ✔️ | ||
| AudioContext.setSrc | ✔️ |