feat: stream currently playing + volume + toggle pause + seek position

This commit is contained in:
2024-11-24 23:36:24 +01:00
parent 51a57ebd40
commit de9e430828
14 changed files with 314 additions and 62 deletions

View File

@@ -9,7 +9,7 @@ use crate::{
checksum::generate_hash,
database::tracks::{get_tracks, insert_tracks},
music::metadata::{extract_track_data, TrackMetadata},
proto::{self, library_server::Library},
proto::library::{library_server::Library, Track, TrackList},
state::GrooveState,
};
@@ -30,7 +30,7 @@ impl Library for LibraryService {
async fn list_tracks(
&self,
_request: tonic::Request<()>,
) -> Result<tonic::Response<proto::TrackList>, tonic::Status> {
) -> Result<tonic::Response<TrackList>, tonic::Status> {
let Ok(db) = self.pool.get() else {
return Err(tonic::Status::internal(""));
};
@@ -39,16 +39,17 @@ impl Library for LibraryService {
return Err(tonic::Status::internal(""));
};
let response = proto::TrackList {
let response = TrackList {
tracks: tracks
.iter()
.map(|t| proto::Track {
.map(|t| Track {
hash: t.hash.clone(),
name: t.name.clone(),
artist_name: t.artist_name.clone(),
artist_id: t.artist_id,
duration: t.duration,
})
.collect::<Vec<proto::Track>>(),
.collect::<Vec<Track>>(),
};
Ok(tonic::Response::new(response))