mirror of
https://github.com/Dummi26/musicdb.git
synced 2025-12-14 20:06:16 +01:00
sequence numbers
This commit is contained in:
@@ -16,6 +16,9 @@ rocket = { version = "0.5.0", optional = true }
|
||||
html-escape = { version = "0.2.13", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["website", "playback"]
|
||||
default = ["website", "default-playback"]
|
||||
website = ["dep:tokio", "dep:rocket", "dep:html-escape"]
|
||||
playback = ["musicdb-lib/playback"]
|
||||
playback = []
|
||||
default-playback = ["playback", "musicdb-lib/default-playback"]
|
||||
playback-via-playback-rs = ["playback", "musicdb-lib/playback-via-playback-rs"]
|
||||
playback-via-rodio = ["playback", "musicdb-lib/playback-via-rodio"]
|
||||
|
||||
@@ -149,8 +149,8 @@ fn main() {
|
||||
writeln!(con, "main").unwrap();
|
||||
loop {
|
||||
let cmd = musicdb_lib::server::Command::from_bytes(&mut con).unwrap();
|
||||
use musicdb_lib::server::Command::*;
|
||||
match &cmd {
|
||||
use musicdb_lib::server::Action::*;
|
||||
match &cmd.action {
|
||||
// ignore playback and queue commands
|
||||
Resume | Pause | Stop | NextSong | QueueUpdate(..) | QueueAdd(..)
|
||||
| QueueInsert(..) | QueueRemove(..) | QueueMove(..) | QueueMoveInto(..)
|
||||
|
||||
@@ -7,7 +7,7 @@ use musicdb_lib::data::database::Database;
|
||||
use musicdb_lib::data::queue::{Queue, QueueContent, QueueFolder};
|
||||
use musicdb_lib::data::song::Song;
|
||||
use musicdb_lib::data::SongId;
|
||||
use musicdb_lib::server::Command;
|
||||
use musicdb_lib::server::{Action, Command};
|
||||
use rocket::response::content::RawHtml;
|
||||
use rocket::{get, routes, Config, State};
|
||||
|
||||
@@ -258,56 +258,62 @@ fn gen_queue_html_impl(
|
||||
fn queue_remove(data: &State<Data>, path: &str) {
|
||||
if let Some(path) = path.split('_').map(|v| v.parse().ok()).collect() {
|
||||
data.command_sender
|
||||
.send(Command::QueueRemove(path))
|
||||
.send(Action::QueueRemove(path).cmd(0xFFu8))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
#[get("/queue-goto/<path>")]
|
||||
fn queue_goto(data: &State<Data>, path: &str) {
|
||||
if let Some(path) = path.split('_').map(|v| v.parse().ok()).collect() {
|
||||
data.command_sender.send(Command::QueueGoto(path)).unwrap();
|
||||
data.command_sender
|
||||
.send(Action::QueueGoto(path).cmd(0xFFu8))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/play")]
|
||||
fn play(data: &State<Data>) {
|
||||
data.command_sender.send(Command::Resume).unwrap();
|
||||
data.command_sender
|
||||
.send(Action::Resume.cmd(0xFFu8))
|
||||
.unwrap();
|
||||
}
|
||||
#[get("/pause")]
|
||||
fn pause(data: &State<Data>) {
|
||||
data.command_sender.send(Command::Pause).unwrap();
|
||||
data.command_sender.send(Action::Pause.cmd(0xFFu8)).unwrap();
|
||||
}
|
||||
#[get("/stop")]
|
||||
fn stop(data: &State<Data>) {
|
||||
data.command_sender.send(Command::Stop).unwrap();
|
||||
data.command_sender.send(Action::Stop.cmd(0xFFu8)).unwrap();
|
||||
}
|
||||
#[get("/skip")]
|
||||
fn skip(data: &State<Data>) {
|
||||
data.command_sender.send(Command::NextSong).unwrap();
|
||||
data.command_sender
|
||||
.send(Action::NextSong.cmd(0xFFu8))
|
||||
.unwrap();
|
||||
}
|
||||
#[get("/clear-queue")]
|
||||
fn clear_queue(data: &State<Data>) {
|
||||
data.command_sender
|
||||
.send(Command::QueueUpdate(
|
||||
vec![],
|
||||
QueueContent::Folder(QueueFolder {
|
||||
index: 0,
|
||||
content: vec![],
|
||||
name: String::new(),
|
||||
order: None,
|
||||
})
|
||||
.into(),
|
||||
))
|
||||
.send(
|
||||
Action::QueueUpdate(
|
||||
vec![],
|
||||
QueueContent::Folder(QueueFolder {
|
||||
index: 0,
|
||||
content: vec![],
|
||||
name: String::new(),
|
||||
order: None,
|
||||
})
|
||||
.into(),
|
||||
)
|
||||
.cmd(0xFFu8),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[get("/add-song/<id>")]
|
||||
fn add_song(data: &State<Data>, id: SongId) {
|
||||
data.command_sender
|
||||
.send(Command::QueueAdd(
|
||||
vec![],
|
||||
vec![QueueContent::Song(id).into()],
|
||||
))
|
||||
.send(Action::QueueAdd(vec![], vec![QueueContent::Song(id).into()]).cmd(0xFFu8))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user