Audio Playback Ended

This event is triggered whenever playback ends for a sound instance played using the audio_play_sound_ functions.

Playback of a sound ends in the following situations: 

The event will trigger in all objects that have it, for any sound played in the game (even when it's not played by the same object).

The event returns information in the async_load ds_map. The map contains the following keys in case of an Audio Playback Ended event: 

NOTE Pausing a sound does not end playback, as playback can still be resumed afterwards.

Example

Suppose you play a sound using any of the audio_play_sound_ functions: 

ins_snd_bgm = audio_play_sound(snd_music, 100, false);

If you call no other sound functions on this sound, it will play until the end. At that point, the Audio Playback Ended event is triggered for the sound. The async_load ds_map will contain the following values in that case: 

If you stop the sound before it reaches its end, the Audio Playback Ended event is triggered as well. This can be done using any of the following lines of code: 

// Stop the sound instance
audio_stop_sound(ins_snd_bgm);

// Stop all instances of the sound asset
audio_stop_sound(snd_relaxed);

// Stop all sounds that are playing
audio_stop_all();

In this case, the sound was stopped through a call to one of the audio_stop_ functions, so instead of being false"was_stopped" will be true here.

Finally, if you start playing additional sounds with a higher priority while this sound is playing, these will also take up a channel (or a voice). If no free channels are left then ins_snd_bgm may be forced to stop and the Audio Playback Ended event is triggered. In this case, "was_stopped" is also set to true.