# Stop Music

## Description

```javascript
'stop music [music_id] [with fade <time>]'
```

The stop music action will let you stop either all music currently playing or only one in specific. To learn more about music, read the [Play Music documentation](/documentation/script-actions/play-music.md).

**Action ID**: `Stop`

**Reversible**: Yes (restores the previously playing music from history)

**Requires User Interaction**: No

## Parameters

| Name      | Type     | Description                                                                                       |
| --------- | -------- | ------------------------------------------------------------------------------------------------- |
| music\_id | `string` | Optional. The name of the specific music you want to stop. If omitted, all music will be stopped. |
| fade      | `number` | Optional. Fade out time in seconds.                                                               |

## Examples

### Stop a Specific Music

The following will stop a specific music track, identified by its name.

{% tabs %}
{% tab title="Script" %}

```javascript
monogatari.script({
    'Start': [
        'play music mainTheme with loop',
        'play music mystery with loop',
        'Two songs are currently playing',
        'stop music mainTheme',
        'Only the mystery song is playing now',
        'end'
    ]
});
```

{% endtab %}

{% tab title="Music Assets" %}

```javascript
monogatari.assets('music', {
    'mainTheme': 'mainThemeSong.mp3',
    'mystery': 'mysterious_song.ogg'
});
```

{% endtab %}
{% endtabs %}

### Stop All Music

The following will stop all music currently playing.

{% tabs %}
{% tab title="Script" %}

```javascript
monogatari.script({
    'Start': [
        'play music mainTheme with loop',
        'play music mystery with loop',
        'Two songs are currently playing',
        'stop music',
        'No music is playing anymore',
        'end'
    ]
});
```

{% endtab %}

{% tab title="Music Assets" %}

```javascript
monogatari.assets('music', {
    'mainTheme': 'mainThemeSong.mp3',
    'mystery': 'mysterious_song.ogg'
});
```

{% endtab %}
{% endtabs %}

### Fade Out Effect

The following will stop the music with a fade out effect. You can also use a fade out effect when stopping all music.

{% tabs %}
{% tab title="Script" %}

```javascript
monogatari.script({
    'Start': [
        'play music mainTheme with loop',
        'play music mystery with loop',
        'Two songs are currently playing',
        'stop music mystery with fade 5',
        'The mystery music is fading out over 5 seconds',
        'end'
    ]
});
```

{% endtab %}

{% tab title="Music Assets" %}

```javascript
monogatari.assets('music', {
    'mainTheme': 'mainThemeSong.mp3',
    'mystery': 'mysterious_song.ogg'
});
```

{% endtab %}
{% endtabs %}

### Fade Out All Music

```javascript
'stop music with fade 3'  // Fade out all music over 3 seconds
```

## Related Actions

* [Play Music](/documentation/script-actions/play-music.md) - Play background music
* [Pause](https://github.com/Monogatari/Documentation/blob/master/script-actions/pause.md) - Pause playing media (can be resumed later)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.monogatari.io/documentation/script-actions/stop-music.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
