From be750665491f8f1b2f3581d26b0544bb1763b571 Mon Sep 17 00:00:00 2001 From: structix Date: Mon, 16 Mar 2026 17:36:18 +0100 Subject: [PATCH] Fix sync mpris thread And remove userinterface --- src/main.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index f7690b2..366421b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,8 @@ mod database; mod http_server; mod player; -mod userinterface; -use std::{env::args, sync::Arc, thread::sleep, time::Duration}; +use std::{env::args, sync::Arc, time::Duration}; use tokio::{join, sync::watch}; @@ -67,7 +66,7 @@ async fn main() { let (mpris_tx, mut mpris_rx) = watch::channel((String::new(), String::new())); let mpris_tx_http = mpris_tx.clone(); - tokio::spawn(async move { + std::thread::spawn(move || { let player = player::MprisPlayer::new().expect("Could not create player"); loop { if let Ok((interpret, track)) = player.get_interpret_and_track() { @@ -76,7 +75,7 @@ async fn main() { } } // Use the std sleep here to avoid an await which will requires player to be Send. - sleep(Duration::from_millis(10)); + std::thread::sleep(Duration::from_millis(1000)); } }); @@ -94,17 +93,17 @@ async fn main() { } } - loop { - let (usernumber, userrating) = userinterface::get_user_rating(&db) - .await - .expect("Can not get user input"); - let (interpret, track) = (*mpris_rx.borrow_and_update()).clone(); + //loop { + // let (usernumber, userrating) = userinterface::get_user_rating(&db) + // .await + // .expect("Can not get user input"); + // let (interpret, track) = (*mpris_rx.borrow_and_update()).clone(); - if let Err(e) = db - .user_add_rating(usernumber, &interpret, &track, userrating) - .await - { - eprintln!("{e}"); - } - } + // if let Err(e) = db + // .user_add_rating(usernumber, &interpret, &track, userrating) + // .await + // { + // eprintln!("{e}"); + // } + //} }