# Playback

Use these examples after [setting up Melodix](<https://melodix.keshon.ru/docs/running.md>) and hearing a first
track. In Discord, join a voice channel before starting playback. Each server
has its own player and queue.

## Play a link or query

```text
/play never gonna give you up
/play https://www.youtube.com/watch?v=dQw4w9WgXcQ
/play http://stream-uk1.radioparadise.com/aac-320
```

A bare query selects a YouTube result. You can also supply a SoundCloud track
link or an internet radio stream URL. SoundCloud and radio need FFmpeg on the
machine running the bot. Source and parser options are advanced overrides;
leave them automatic until the normal path works.

## Choose a search result

Use `/search` with a query to see five results with uploader and duration, then
press the numbered button for the track you want. A pick starts playback or
adds to the queue. Its Now Playing status is public; the chooser is private.
The `source` option can select YouTube or SoundCloud.

## Play a playlist or mix

```text
/play https://www.youtube.com/playlist?list=PL...
/play https://www.youtube.com/watch?v=...&list=RD...
```

A YouTube URL with `list=` expands the list, up to 100 tracks. When it also names
a video, that video plays first and the remaining fetched entries follow. To
play only one video, remove the `list=` part. Mixes are generated by YouTube and
can differ on later requests.

## Manage the queue

- `/queue` shows the current track and waiting tracks.
- Another `/play` while music is playing adds tracks behind it.
- `/next` skips the current track and starts the next available entry.
- `/stop` stops playback and clears the queue.

When the queue finishes, the bot leaves the voice channel. Queues survive a
Discord session reconnect but are cleared by restarting the Melodix process.
Loop, shuffle, seek, pause and resume are not available. Melodix has no audio
filters or bot volume command; Discord's per-user volume still works.

## Replay history

Use `/history` to find an entry's ID, then:

```text
/play 42
/play 45 16 15
```

The second command queues those entries in that order. History records tracks
that produced audio, not every failed request. It is separate from the optional
audio cache: a history entry can require a new network fetch. See
[storage and restart behavior](<https://melodix.keshon.ru/docs/running.md#persistent-data-and-restart-behavior>).

## Terminal player

Start `melodix-cli` as described in [Running Melodix](<https://melodix.keshon.ru/docs/running.md#cli-player>).
Use commands without a slash:

```text
play never gonna give you up
search take on me
queue
next
history
stop
quit
```

Search asks which result to queue. `play <link|query|history ids>` also accepts
`source=youtube|soundcloud|radio` and a parser override; `search` supports
`source=youtube|soundcloud`. Run `help` for current usage. The small library
example is a different program with a smaller command set.

## Find commands or diagnose a failure

Discord `/help flat` and terminal `help` describe the running version. The
[generated README catalog](<https://github.com/keshon/melodix/blob/b191282f08193ccf22c8c0215d786e6069e317f8/README.md#commands>) is a reference for this source
revision. Missing commands, failures and silent audio are covered in
[Troubleshooting](<https://melodix.keshon.ru/docs/troubleshooting.md>).
