# Detect end of sound playing with SDL\_mixer

**URL:** <https://discourse.libsdl.org/t/detect-end-of-sound-playing-with-sdl-mixer/28251>\
**Category:** Game Development\
**Created:** [October 14, 2020, 12:12pm UTC](https://discourse.libsdl.org/t/detect-end-of-sound-playing-with-sdl-mixer/28251 "2020-10-14T12:12:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![markand](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/markand/32/5226_2.png) [@markand](https://discourse.libsdl.org/u/markand)\
**Post date:** [October 14, 2020, 12:12pm UTC](https://discourse.libsdl.org/t/detect-end-of-sound-playing-with-sdl-mixer/28251/1 "2020-10-14T12:12:53Z")

</div>

Hi there,

I’ve never played that much with SDL\_mixer or mostly to do basic things. For now I’m trying to figure out a simple way to detect that all sounds have been played entirely.

For example, let say I open two sounds which are 3 seconds and 5 seconds respectively.

If I start playing them using Mix\_PlayChannel I can specify a channel, but I’ve always used -1 because I didn’t care that much. I must say that I have a very bare knowledges about use of channels. What will be the easiest way to know when those sounds finished playing? Using Mix\_Playing?

What is the usual way of using them? Like having a channel for sounds effects? One for user interaction? One for gameplay?

I’m also trying to understand when to use channels and groups.

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![AntTheAlchemist](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/antthealchemist/32/3894_2.png) [@AntTheAlchemist](https://discourse.libsdl.org/u/AntTheAlchemist)\
**Post date:** [October 18, 2020, 1:24am UTC](https://discourse.libsdl.org/t/detect-end-of-sound-playing-with-sdl-mixer/28251/2 "2020-10-18T01:24:27Z")

</div>

Hi,

I would stick to using -1 to let `Mix_PlayChannel` choose a channel for you. I guess it chooses the first free channel it can find. You’re unlikely to need to use channel groups, and there’s no use to reserving channels for UI and game. Channels are just there to allow more than one sound to play at the same time.

If you really want to be notified of when a sound finishes then `Mix_ChannelFinished` works well. This can be useful for when you want to change the panning or volume of a sound you played earlier because the sound is moving. You’d only want to apply the change to the channel if it’s still playing and a new sound isn’t playing in its place.
