title: AudioContext
sidebar_label: 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
API |
WeChat Mini-Program |
H5 |
React Native |
AudioContext.pause |
✔️ |
|
play
Plays an audio file.
Reference
() => void
API Support
API |
WeChat Mini-Program |
H5 |
React Native |
AudioContext.play |
✔️ |
|
seek
Jumps to the specific position in the audio file.
Reference
(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.
Reference
(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 |
✔️ |
|
|