Please provide the following:
- SDK Version: “34.0.0”
- Platforms": Android/iOS
Hi everyone.
I’m just trying to find a way to detect when my first sound has finished playing, so I can start the next one. Is this possible?
It looks like onPlaybackStatusUpdate
might give me what I’m after, but I can’t work out how to apply it for my use case.
I’m not sure if this is useful or not, but here is my current code in case:
PS: Thanks for any help!
async componentWillMount() {
this.heartBeat = new Audio.Sound();
await this.heartBeat.loadAsync(require("./hearbeat.mp3"));
await Audio.setAudioModeAsync({
playsInSilentModeIOS: true,
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS,
shouldDuckAndroid: false,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
playThroughEarpieceAndroid: true,
staysActiveInBackground: true
});
await Audio.setIsEnabledAsync(true);
await this.heartBeat.setPositionAsync(0);
}
handlePlaySound = async () => {
try {
await this.heartBeat.setPositionAsync(0);
await this.heartBeat.playAsync();
} catch (error) {
console.log("ERROR", error);
}
};
handleStopSound = async val => {
try {
await this.heartBeat.setPositionAsync(0);
await this.heartBeat.stopAsync();
} catch (error) {
console.log("ERROR", error);
}
};