Hi all, I want to know when a music in my game ends, I am trying to use AudioSource.EventType.ENDED event, but it calls only for first ended audio:
node.on(AudioSource.EventType.ENDED, (arg1) => {
console.log(arg1);
});
Hi all, I want to know when a music in my game ends, I am trying to use AudioSource.EventType.ENDED event, but it calls only for first ended audio:
node.on(AudioSource.EventType.ENDED, (arg1) => {
console.log(arg1);
});
I can ask engineering to have a look.
What version of Creator are you using?
Cocos Creator 3.4.0
I tested that I can always listen to the ENDED callback. The premise is that loop = false.
you can also get the current playback status to determine if the playback is over.
let state = this.BGAudiosource.playing;
Or get the current playback time and compare it with the audio duration using currentTime.
let currentTime = this.BGAudiosource.currentTime;
let duration = this.BGAudiosource.duration;
.