I want to play an audio sound an amount of time. Is there anyway that you can determine the number of time you can loop an audio? In expo, i only see a the state for a sound: isLooping: true. This will loop the sound endlessly, not a certain amount of time! Down here is my code on state of the sound and where i play the sound
//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();
}
}
};
Please have a look at this , it illustrates how you can loop exactly 20 times.
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.