feat: playback-via-mpv, rust 2024

This commit is contained in:
Mark
2026-04-15 22:07:49 +02:00
committed by Mark
parent 8d4d418166
commit ab17477285
12 changed files with 460 additions and 94 deletions

View File

@@ -46,6 +46,77 @@ https://github.com/Dummi26/musicdb/assets/67615357/afb0c9fa-3cf0-414a-a59f-7e462
# Setup
## building
Run `cargo build --release` in `musicdb-filldb`, `musicdb-server`, and `musicdb-client`.
The executable files will be `musicdb-*/target/release/musicdb-*`.
### building the server
You may need to install `libasound2-dev` or similar packages,
as the default audio backend likely requires it.
If this is the case, you will likely see `error: ld returned 1 exit status`.
Multiple backends are available for playing audio,
but using `default-playback` should be fine most of the time.
If compilation fails or you experience an audio related issue,
try compiling with a different backend and see if the issue persists:
```sh
# in musicdb-server
cargo build --release --no-default-features --features website,playback-via-$backend
```
#### backends
The `rodio` and `playback-rs` backends are named after the libraries they use.
These pull in dependencies and may try to link to system libraries.
The `mpv` backend executes the `mpv` media player to play audio.
If you can't compile other backends, use this.
This backend will spawn up to two `mpv` processes at a time
and control them using unix sockets in `/tmp/`.
The `sleep` backend doesn't play any audio. Instead,
it waits for the duration of the song and then moves
on to the next one. If you want to connect
(audio-playing) servers or (web) clients
to one server where the audio files are stored but which
doesn't play any audio itself, you can use this backend.
If the duration of a song is unknown, the song will be played
for a duration of zero seconds, meaning it will just get skipped
(although connected servers or clients may still load the song
and may even succeed in playing it).
#### other features
The `website` feature is required for `--web <addr>` to work.
It allows the server to handle http requests so that it
can be controlled without using `musicdb-client`.
Turning this off improves compile times and stuff,
but leaving the feature on is quite useful
(e.g. to pause/resume playback from a phone).
### building the client
The client can play audio in sync with the server.
If you don't need this, you don't need to compile it:
```sh
# in musicdb-client
cargo build --release --no-default-features --features gui
```
Instead of disabling playback, you can also choose
from the backends available to the server.
Read "compiling the server" for more information.
In the future, it may make sense to disable the `gui` feature too
(e.g. the client may act as a cli tool for scripts), but not yet.
## setup.sh
Review, then run the `setup.sh` script:
```sh
@@ -64,8 +135,11 @@ font = '/usr/share/fonts/...'
...
```
The script will start a server and client.
After closing the client, the server may still be running, so you may have to `pkill musicdb-server` if you want to stop it.
## manually
The `setup.sh` script will start a server and client.
After closing the client, the server remains active.
You have to `pkill musicdb-server` if you want to stop it.
To open the player again:
@@ -73,7 +147,7 @@ To open the player again:
musicdb-client 0.0.0.0:26002 gui
```
To start the server:
To start the server without `setup.sh`:
```sh
musicdb-server --tcp 0.0.0.0:26002 --play-audio local ~/my_dbdir ~/music