mirror of
https://github.com/Dangoware/dmp-core.git
synced 2025-04-19 17:42:55 -05:00
Ran cargo fmt
This commit is contained in:
parent
17c2745cdd
commit
b2e7367795
4 changed files with 64 additions and 40 deletions
|
@ -18,10 +18,7 @@ impl MusicController {
|
|||
Err(error) => return Err(error),
|
||||
};
|
||||
|
||||
let controller = MusicController {
|
||||
config,
|
||||
library,
|
||||
};
|
||||
let controller = MusicController { config, library };
|
||||
|
||||
Ok(controller)
|
||||
}
|
||||
|
@ -34,10 +31,7 @@ impl MusicController {
|
|||
Err(error) => return Err(error),
|
||||
};
|
||||
|
||||
let controller = MusicController {
|
||||
config,
|
||||
library,
|
||||
};
|
||||
let controller = MusicController { config, library };
|
||||
|
||||
Ok(controller)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Crate things
|
||||
//use crate::music_controller::config::Config;
|
||||
use crate::music_storage::music_db::{URI, Tag};
|
||||
use crate::music_storage::music_db::{Tag, URI};
|
||||
use crossbeam_channel::bounded;
|
||||
use std::error::Error;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
@ -52,7 +52,7 @@ impl TryInto<gst::State> for PlayerState {
|
|||
Self::Paused => Ok(gst::State::Paused),
|
||||
Self::Ready => Ok(gst::State::Ready),
|
||||
Self::Null => Ok(gst::State::Null),
|
||||
state => Err(format!("Invalid gst::State: {:?}", state).into())
|
||||
state => Err(format!("Invalid gst::State: {:?}", state).into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,10 +177,22 @@ impl Player {
|
|||
.expect("Failed to get GStreamer message bus")
|
||||
.add_watch(move |_bus, msg| {
|
||||
match msg.view() {
|
||||
gst::MessageView::Eos(_) => {},
|
||||
gst::MessageView::StreamStart(_) => {},
|
||||
gst::MessageView::Error(e) =>
|
||||
println!("song {}", e.error()),
|
||||
gst::MessageView::Eos(_) => {}
|
||||
gst::MessageView::StreamStart(_) => println!("Stream start"),
|
||||
gst::MessageView::Error(e) => {
|
||||
println!("ERROR: {}", e.error());
|
||||
playbin_bus_ctrl
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_state(gst::State::Ready)
|
||||
.unwrap();
|
||||
|
||||
playbin_bus_ctrl
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_state(gst::State::Playing)
|
||||
.unwrap();
|
||||
},
|
||||
gst::MessageView::Tag(tag) => {
|
||||
if let Some(title) = tag.tags().get::<gst::tags::Title>() {
|
||||
println!(" Title: {}", title.get());
|
||||
|
@ -193,10 +205,18 @@ impl Player {
|
|||
let percent = buffering.percent();
|
||||
if percent < 100 {
|
||||
*buffer_bus_ctrl.write().unwrap() = Some(percent as u8);
|
||||
playbin_bus_ctrl.write().unwrap().set_state(gst::State::Paused).unwrap();
|
||||
playbin_bus_ctrl
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_state(gst::State::Paused)
|
||||
.unwrap();
|
||||
} else if *paused_bus_ctrl.read().unwrap() == false {
|
||||
*buffer_bus_ctrl.write().unwrap() = None;
|
||||
playbin_bus_ctrl.write().unwrap().set_state(gst::State::Playing).unwrap();
|
||||
playbin_bus_ctrl
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_state(gst::State::Playing)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
|
@ -239,7 +259,10 @@ impl Player {
|
|||
self.source = Some(source.clone());
|
||||
match source {
|
||||
URI::Cue { start, end, .. } => {
|
||||
self.playbin.write().unwrap().set_property("uri", source.as_uri());
|
||||
self.playbin
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_property("uri", source.as_uri());
|
||||
|
||||
// Set the start and end positions of the CUE file
|
||||
*self.start.write().unwrap() = Some(Duration::from_std(*start).unwrap());
|
||||
|
@ -258,11 +281,15 @@ impl Player {
|
|||
panic!("Couldn't seek to beginning of cue track in reasonable time (>20ms)");
|
||||
}
|
||||
_ => {
|
||||
self.playbin.write().unwrap().set_property("uri", source.as_uri());
|
||||
self.playbin
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_property("uri", source.as_uri());
|
||||
|
||||
self.play().unwrap();
|
||||
|
||||
while uri.get::<&str>().unwrap_or("") == self.property("current-uri").get::<&str>().unwrap_or("")
|
||||
while uri.get::<&str>().unwrap_or("")
|
||||
== self.property("current-uri").get::<&str>().unwrap_or("")
|
||||
|| self.position().is_none()
|
||||
{
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
|
@ -392,9 +419,7 @@ impl Player {
|
|||
pub fn state(&mut self) -> PlayerState {
|
||||
match *self.buffer.read().unwrap() {
|
||||
None => self.playbin.read().unwrap().current_state().into(),
|
||||
Some(value) => {
|
||||
PlayerState::Buffering(value)
|
||||
}
|
||||
Some(value) => PlayerState::Buffering(value),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ use std::ops::ControlFlow::{Break, Continue};
|
|||
|
||||
// Files
|
||||
use file_format::{FileFormat, Kind};
|
||||
use glib::filename_to_uri;
|
||||
use lofty::{AudioFile, ItemKey, ItemValue, ParseOptions, Probe, TagType, TaggedFileExt};
|
||||
use rcue::parser::parse_from_file;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use walkdir::WalkDir;
|
||||
use glib::filename_to_uri;
|
||||
|
||||
// Time
|
||||
use chrono::{serde::ts_milliseconds_option, DateTime, Utc};
|
||||
|
@ -102,7 +102,7 @@ impl ToString for Field {
|
|||
Self::Rating(rating) => rating.to_string(),
|
||||
Self::Format(format) => match format.short_name() {
|
||||
Some(name) => name.to_string(),
|
||||
None => format.to_string()
|
||||
None => format.to_string(),
|
||||
},
|
||||
Self::Duration(duration) => duration.as_millis().to_string(),
|
||||
Self::PlayTime(time) => time.as_millis().to_string(),
|
||||
|
@ -228,8 +228,12 @@ impl URI {
|
|||
|
||||
pub fn as_uri(&self) -> String {
|
||||
let path_str = match self {
|
||||
URI::Local(location) => filename_to_uri(location, None).expect("couldn't convert path to URI").to_string(),
|
||||
URI::Cue { location, .. } => filename_to_uri(location, None).expect("couldn't convert path to URI").to_string(),
|
||||
URI::Local(location) => filename_to_uri(location, None)
|
||||
.expect("couldn't convert path to URI")
|
||||
.to_string(),
|
||||
URI::Cue { location, .. } => filename_to_uri(location, None)
|
||||
.expect("couldn't convert path to URI")
|
||||
.to_string(),
|
||||
URI::Remote(_, location) => location.clone(),
|
||||
};
|
||||
path_str.to_string()
|
||||
|
@ -492,7 +496,7 @@ impl MusicLibrary {
|
|||
None => blank_tag,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Err(_) => blank_tag,
|
||||
};
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use file_format::{FileFormat, Kind};
|
||||
use std::io::{BufReader, BufWriter};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{error::Error, fs};
|
||||
use walkdir::WalkDir;
|
||||
use file_format::{FileFormat, Kind};
|
||||
|
||||
use snap;
|
||||
|
||||
use super::music_db::{Song, AlbumArt, URI};
|
||||
use super::music_db::{AlbumArt, Song, URI};
|
||||
use unidecode::unidecode;
|
||||
|
||||
pub(super) fn normalize(input_string: &str) -> String {
|
||||
|
@ -76,8 +76,9 @@ pub fn find_images(song_path: &Path) -> Result<Vec<AlbumArt>, Box<dyn Error>> {
|
|||
.into_iter()
|
||||
.filter_map(|e| e.ok())
|
||||
{
|
||||
if target_file.depth() >= 3 { // Don't recurse very deep
|
||||
break
|
||||
if target_file.depth() >= 3 {
|
||||
// Don't recurse very deep
|
||||
break;
|
||||
}
|
||||
|
||||
let path = target_file.path();
|
||||
|
@ -87,7 +88,7 @@ pub fn find_images(song_path: &Path) -> Result<Vec<AlbumArt>, Box<dyn Error>> {
|
|||
|
||||
let format = FileFormat::from_file(path)?.kind();
|
||||
if format != Kind::Image {
|
||||
break
|
||||
break;
|
||||
}
|
||||
|
||||
let image_uri = URI::Local(path.to_path_buf().canonicalize().unwrap());
|
||||
|
|
Loading…
Reference in a new issue