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/>.
*/
use dbus::ffidisp::Connection;
use mpris::{FindingError, PlaybackStatus, Player, PlayerFinder, ProgressTick};
use serde::Serialize;
use std::{
path::PathBuf,
sync::mpsc::{channel, Receiver, Sender, TryRecvError},
thread,
time::Duration,
};
use std::time::Duration;
use thiserror::Error;
pub enum Message {
@ -39,17 +32,6 @@ pub struct DeviceInformation {
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)]
pub enum AudioError {
#[error("DBus device was not found")]
@ -122,38 +104,6 @@ pub struct TrackInfo {
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)]
#[serde(rename_all = "camelCase")]
pub enum State {
@ -162,10 +112,12 @@ pub enum State {
Stopped,
}
/*
pub struct CurrentlyPlaying {
track: TrackInfo,
position: Duration,
}
*/
#[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
@ -183,6 +135,7 @@ pub trait AudioPlayer {
fn play_pause(&self) -> Result<State, AudioError>;
}
/*
pub struct GStreamerPlayer {
url: url::Url,
}
@ -204,6 +157,7 @@ impl AudioPlayer for GStreamerPlayer {
unimplemented!()
}
}
*/
/*
pub struct MprisDevice {

View File

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

View File

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