Render a file list from the filesystem #24

Merged
savanni merged 9 commits from track-list into main 2023-02-26 03:17:01 +00:00
3 changed files with 9 additions and 68 deletions
Showing only changes of commit e7cb044a5c - Show all commits

View File

@ -10,15 +10,8 @@ Luminescent Dreams Tools is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>. You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/ */
use dbus::ffidisp::Connection;
use mpris::{FindingError, PlaybackStatus, Player, PlayerFinder, ProgressTick};
use serde::Serialize; use serde::Serialize;
use std::{ use std::time::Duration;
path::PathBuf,
sync::mpsc::{channel, Receiver, Sender, TryRecvError},
thread,
time::Duration,
};
use thiserror::Error; use thiserror::Error;
pub enum Message { pub enum Message {
@ -39,17 +32,6 @@ pub struct DeviceInformation {
pub name: String, pub name: String,
} }
pub fn list_devices(conn: Connection) -> Result<Vec<DeviceInformation>, FindingError> {
Ok(PlayerFinder::for_connection(conn)
.find_all()?
.into_iter()
.map(|player| DeviceInformation {
address: player.unique_name().to_owned(),
name: player.identity().to_owned(),
})
.collect())
}
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum AudioError { pub enum AudioError {
#[error("DBus device was not found")] #[error("DBus device was not found")]
@ -122,38 +104,6 @@ pub struct TrackInfo {
pub artist: Option<String>, pub artist: Option<String>,
} }
/*
#[derive(Clone, Debug, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Track {
pub id: TrackId,
pub track_number: Option<i32>,
pub name: Option<String>,
pub album: Option<String>,
pub artist: Option<String>,
}
*/
/*
impl From<&mpris::Metadata> for Track {
fn from(data: &mpris::Metadata) -> Self {
Self {
id: data.track_id().unwrap(),
track_number: data.track_number(),
name: data.title().map(|s| s.to_owned()),
album: data.album_name().map(|s| s.to_owned()),
artist: None,
}
}
}
impl From<mpris::Metadata> for Track {
fn from(data: mpris::Metadata) -> Self {
Self::from(&data)
}
}
*/
#[derive(Clone, Debug, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub enum State { pub enum State {
@ -162,10 +112,12 @@ pub enum State {
Stopped, Stopped,
} }
/*
pub struct CurrentlyPlaying { pub struct CurrentlyPlaying {
track: TrackInfo, track: TrackInfo,
position: Duration, position: Duration,
} }
*/
#[derive(Clone, Debug, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
@ -183,6 +135,7 @@ pub trait AudioPlayer {
fn play_pause(&self) -> Result<State, AudioError>; fn play_pause(&self) -> Result<State, AudioError>;
} }
/*
pub struct GStreamerPlayer { pub struct GStreamerPlayer {
url: url::Url, url: url::Url,
} }
@ -204,6 +157,7 @@ impl AudioPlayer for GStreamerPlayer {
unimplemented!() unimplemented!()
} }
} }
*/
/* /*
pub struct MprisDevice { pub struct MprisDevice {

View File

@ -1,16 +1,13 @@
use flow::Flow; use flow::Flow;
use std::{ use std::{
io::stdin,
net::{IpAddr, Ipv4Addr, SocketAddr}, net::{IpAddr, Ipv4Addr, SocketAddr},
path::PathBuf, path::PathBuf,
sync::Arc, sync::Arc,
thread,
time::Duration,
}; };
use warp::{Filter, Reply}; use warp::Filter;
use music_player::{ use music_player::{
audio::{TrackId, TrackInfo}, audio::TrackInfo,
core::Core, core::Core,
database::{MemoryIndex, MusicIndex}, database::{MemoryIndex, MusicIndex},
music_scanner::FileScanner, music_scanner::FileScanner,
@ -58,7 +55,7 @@ pub async fn main() {
let index = Arc::new(MemoryIndex::new()); let index = Arc::new(MemoryIndex::new());
let scanner = FileScanner::new(vec![music_root.clone()]); let scanner = FileScanner::new(vec![music_root.clone()]);
let core = match Core::new(index.clone(), scanner) { let _core = match Core::new(index.clone(), scanner) {
Flow::Ok(core) => core, Flow::Ok(core) => core,
Flow::Err(error) => panic!("error: {}", error), Flow::Err(error) => panic!("error: {}", error),
Flow::Fatal(error) => panic!("fatal: {}", error), Flow::Fatal(error) => panic!("fatal: {}", error),

View File

@ -1,17 +1,7 @@
use crate::{ use crate::audio::{TrackId, TrackInfo};
audio::{TrackId, TrackInfo},
core::{ControlMsg, TrackMsg},
database::MusicIndex,
FatalError,
};
use std::{ use std::{
fs::{DirEntry, ReadDir}, fs::{DirEntry, ReadDir},
path::PathBuf, path::PathBuf,
sync::{
mpsc::{Receiver, RecvTimeoutError, Sender},
Arc,
},
time::{Duration, Instant},
}; };
use thiserror::Error; use thiserror::Error;