我想播放一个音频声音一段时间。你是否可以确定循环音频的次数?在世博会上,我只看到一个声音的状态:islooping:true。这将循环的声音无休止,而不是一定量的时间!下面是关于声音状态和我播放声音的位置的代码
//state of the sound
const { sound, status } = await this.recording.createNewLoadedSoundAsync(
{
isLooping: false,
isMuted: this.state.muted,
volume: this.state.volume,
rate: this.state.rate,
shouldCorrectPitch: this.state.shouldCorrectPitch
},
this._updateScreenForSoundStatus
);
//play sound or pause sound when the button is pressed
_onPlayPausePressed = () => {
if (this.sound != null) {
if (this.state.isPlaying) {
this.sound.pauseAsync();
} else {
this.sound.playAsync();
}
}
};
请看一下这个,它说明了如何可以循环20次。
希望这有帮助!