# onClientSoundStopped (Client)

> Fired when a sound stops playing on this client: paused, stopped or finished.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Event
- **Side**: Client
- **Category**: Sound
- **URL**: https://wiki.mymp.gg/en/onClientSoundStopped

## Syntax

```lua
addEventHandler("onClientSoundStopped", root, function(string reason) ... end)
```

## Handler parameters

| Name | Type | Description |
| --- | --- | --- |
| `reason` | `string` | `paused` when it is paused, `destroyed` when `stopSound` stops it, `finished` when it reaches its end. |

## Source

The `sound` element.

With `finished`, a sound of this client is destroyed right after. A server sound keeps existing until the server removes it.

## Example

```lua
local playlist = { "music/1.mp3", "music/2.mp3", "music/3.mp3" }
local current = 1

local function playNext()
    local sound = playSound(playlist[current])
    addEventHandler("onClientSoundStopped", sound, function(reason)
        if reason == "finished" then
            current = current % #playlist + 1
            playNext()
        end
    end)
end
playNext()
```

## See also

- [onClientSoundStarted (Client)](https://wiki.mymp.gg/en/onClientSoundStarted.md): Fired when a sound starts playing on this client or leaves a pause.
- [stopSound (Client)](https://wiki.mymp.gg/en/stopSound-client.md): Stops a sound this client created and destroys the element. Fires onClientSoundStopped with the reason destroyed.
- [setSoundPaused (Shared)](https://wiki.mymp.gg/en/setSoundPaused.md): Pauses or resumes a sound. On the server, the change is sent to every client.
