Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

expose playlist_resume FFI to GraphQL and gRPC

expose playlist_resume FFI to GraphQL and gRPC

expose playlist_resume FFI to GraphQL and gRPC

+23 -3
+10 -2
crates/graphql/src/schema/playlist.rs
··· 1 + use std::sync::{mpsc::Sender, Arc, Mutex}; 2 + 1 3 use async_graphql::*; 4 + use rockbox_sys::events::RockboxCommand; 2 5 3 6 #[derive(Default)] 4 7 pub struct PlaylistQuery; ··· 35 38 36 39 #[Object] 37 40 impl PlaylistMutation { 38 - async fn playlist_resume(&self) -> String { 39 - "playlist resume".to_string() 41 + async fn playlist_resume(&self, ctx: &Context<'_>) -> Result<String, Error> { 42 + ctx.data::<Arc<Mutex<Sender<RockboxCommand>>>>() 43 + .unwrap() 44 + .lock() 45 + .unwrap() 46 + .send(RockboxCommand::PlaylistResume)?; 47 + Ok("playlist resume".to_string()) 40 48 } 41 49 42 50 async fn resume_track(&self) -> String {
+5
crates/rpc/src/playlist.rs
··· 62 62 &self, 63 63 request: tonic::Request<PlaylistResumeRequest>, 64 64 ) -> Result<tonic::Response<PlaylistResumeResponse>, tonic::Status> { 65 + self.cmd_tx 66 + .lock() 67 + .unwrap() 68 + .send(RockboxCommand::PlaylistResume) 69 + .map_err(|_| tonic::Status::internal("Failed to send command"))?; 65 70 Ok(tonic::Response::new(PlaylistResumeResponse::default())) 66 71 } 67 72
+7 -1
crates/server/src/lib.rs
··· 34 34 listener.set_nonblocking(true).unwrap(); 35 35 36 36 println!( 37 - "{} server is listening on {}", 37 + "{} server is running on {}", 38 38 "Rockbox TCP".bright_purple(), 39 39 addr.bright_green() 40 40 ); ··· 90 90 } 91 91 "/stop" => { 92 92 rb::playback::hard_stop(); 93 + } 94 + "/playlist_resume" => { 95 + rb::playlist::resume(); 93 96 } 94 97 _ => { 95 98 if path.starts_with("/play") { ··· 162 165 } 163 166 RockboxCommand::Stop => { 164 167 reqwest::blocking::get(&format!("{}/stop", url)).unwrap(); 168 + } 169 + RockboxCommand::PlaylistResume => { 170 + reqwest::blocking::get(&format!("{}/playlist_resume", url)).unwrap(); 165 171 } 166 172 } 167 173 }
+1
crates/sys/src/events.rs
··· 7 7 FfRewind(i32), 8 8 FlushAndReloadTracks, 9 9 Stop, 10 + PlaylistResume, 10 11 }