# Handlers

### Start

```lua
exports['mx-surround']:onPlayStart(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Stop

```lua
exports['mx-surround']:onPlayEnd(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Pause

```lua
exports['mx-surround']:onPlayPause(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Resume

```lua
exports['mx-surround']:onPlayResume(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Loading

```lua
exports['mx-surround']:onLoading(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Attach

```lua
exports['mx-surround']:onAttachEntity(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Detach

```lua
exports['mx-surround']:onDetachEntity(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Destroy

```lua
exports['mx-surround']:onDestroy(soundId, fn)
```

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

### Time Update

```lua
exports['mx-surround']:onTimeUpdate(soundId, fn)
```

{% hint style="info" %}
This handler is triggered when the current time changed
{% endhint %}

#### Parameters

* > **soundId:** `string`
* > **fn:** `function`

***

### Directly Set

```lua
exports['mx-surround']:setSoundHandler(soundId, data)
```

#### Parameters

* > **soundId:** `string`
* > **data:** `table`
  >
  > > * **destroy:** `function`
  > > * **start**: `function`
  > > * **stop**: `function`
  > > * **pause**: `function`
  > > * **resume**: `function`
  > > * **loading**: `function`
  > > * **attach**: `function`
  > > * **detach**: `function`
  > > * **timeupdate:** `function`
  > > * **end:** `function`
