我想播放音频一段时间。无论如何,您是否可以确定循环音频的时间?在博览会上,我只看到声音的状态: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();
}
}
};