Ignore unsupported file extensions in files by default and make OS media controls sort of optional
This commit is contained in:
parent
73aae27148
commit
e93d79f28d
4 changed files with 48 additions and 16 deletions
|
@ -16,6 +16,12 @@ members = [
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# local
|
# local
|
||||||
mps-interpreter = { version = "0.2.0", path = "./mps-interpreter" }
|
mps-interpreter = { version = "0.2.0", path = "./mps-interpreter" }
|
||||||
mps-player = { version = "0.2.0", path = "./mps-player" }
|
|
||||||
# external
|
# external
|
||||||
clap = { version = "3.0", features = ["derive"] }
|
clap = { version = "3.0", features = ["derive"] }
|
||||||
|
|
||||||
|
[target.'cfg(not(target_os = "linux"))'.dependencies]
|
||||||
|
mps-player = { version = "0.2.0", path = "./mps-player", default-features = false }
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
# TODO fix need to specify OS-specific dependency of mps-player
|
||||||
|
mps-player = { version = "0.2.0", path = "./mps-player", features = ["mpris-player"] }
|
||||||
|
|
|
@ -9,7 +9,7 @@ use super::OpGetter;
|
||||||
use crate::lang::RuntimeError;
|
use crate::lang::RuntimeError;
|
||||||
use crate::MpsMusicItem;
|
use crate::MpsMusicItem;
|
||||||
|
|
||||||
const DEFAULT_REGEX: &str = r"/(?P<artist>[^/]+)/(?P<album>[^/]+)/(?:(?:(?P<disc>\d+)\s+)?(?P<track>\d+)\.?\s+)?(?P<title>[^/]+)\.[a-zA-Z0-9]+$";
|
const DEFAULT_REGEX: &str = r"/(?P<artist>[^/]+)/(?P<album>[^/]+)/(?:(?:(?P<disc>\d+)\s+)?(?P<track>\d+)\.?\s+)?(?P<title>[^/]+)\.(?P<format>(?:mp3)|(?:wav)|(?:ogg)|(?:flac)|(?:mp4)|(?:aac))$";
|
||||||
|
|
||||||
const DEFAULT_VEC_CACHE_SIZE: usize = 4;
|
const DEFAULT_VEC_CACHE_SIZE: usize = 4;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,19 @@ m3u8-rs = { version = "^3.0.0" }
|
||||||
# local
|
# local
|
||||||
mps-interpreter = { path = "../mps-interpreter", version = "0.2.0" }
|
mps-interpreter = { path = "../mps-interpreter", version = "0.2.0" }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
#dbus = { version = "^0.9" }
|
#dbus = { version = "^0.9" }
|
||||||
mpris-player = { version = "^0.6.1", path = "../mpris-player" }
|
mpris-player = { version = "^0.6.1", path = "../mpris-player", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["os-controls"]
|
||||||
|
os-controls = []
|
||||||
|
|
||||||
|
# I wish this worked...
|
||||||
|
#[target.'cfg(not(target_os = "linux"))'.features]
|
||||||
|
#default = ["os-controls"]
|
||||||
|
#os-controls = []
|
||||||
|
|
||||||
|
#[target.'cfg(target_os = "linux")'.features]
|
||||||
|
#default = ["os-controls"]
|
||||||
|
#os-controls = ["mpris-player"]
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#[cfg(unix)]
|
#[allow(unused_imports)]
|
||||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||||
#[cfg(unix)]
|
#[cfg(all(target_os = "linux", feature = "os-controls"))]
|
||||||
use std::thread::JoinHandle;
|
use std::thread::JoinHandle;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(all(target_os = "linux", feature = "os-controls"))]
|
||||||
use mpris_player::{MprisPlayer, PlaybackStatus, Metadata};
|
use mpris_player::{MprisPlayer, PlaybackStatus, Metadata};
|
||||||
|
|
||||||
|
#[cfg(all(target_os = "linux", feature = "os-controls"))]
|
||||||
use mps_interpreter::MpsMusicItem;
|
use mps_interpreter::MpsMusicItem;
|
||||||
|
|
||||||
//use super::MpsController;
|
//use super::MpsController;
|
||||||
|
@ -13,25 +14,32 @@ use super::player_wrapper::{ControlAction, PlaybackAction};
|
||||||
|
|
||||||
/// OS-specific APIs for media controls.
|
/// OS-specific APIs for media controls.
|
||||||
/// Currently only Linux (dbus) is supported.
|
/// Currently only Linux (dbus) is supported.
|
||||||
|
#[cfg(all(target_os = "linux", feature = "os-controls"))]
|
||||||
pub struct SystemControlWrapper {
|
pub struct SystemControlWrapper {
|
||||||
control: Sender<ControlAction>,
|
control: Sender<ControlAction>,
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
dbus_handle: Option<JoinHandle<()>>, //std::sync::Arc<MprisPlayer>,
|
dbus_handle: Option<JoinHandle<()>>, //std::sync::Arc<MprisPlayer>,
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
dbus_ctrl: Option<Sender<DbusControl>>,
|
dbus_ctrl: Option<Sender<DbusControl>>,
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
playback_event_handler: Option<JoinHandle<()>>,
|
playback_event_handler: Option<JoinHandle<()>>,
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
playback_event_handler_killer: Option<Sender<()>>,
|
playback_event_handler_killer: Option<Sender<()>>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
/// OS-specific APIs for media controls.
|
||||||
|
/// Currently only Linux (dbus) is supported.
|
||||||
|
#[cfg(not(feature = "os-controls"))]
|
||||||
|
pub struct SystemControlWrapper {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
control: Sender<ControlAction>,
|
||||||
|
playback_receiver: Option<Receiver<PlaybackAction>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(all(target_os = "linux", feature = "os-controls"))]
|
||||||
enum DbusControl {
|
enum DbusControl {
|
||||||
Die,
|
Die,
|
||||||
SetMetadata(Metadata),
|
SetMetadata(Metadata),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(all(target_os = "linux", feature = "os-controls"))]
|
||||||
impl SystemControlWrapper {
|
impl SystemControlWrapper {
|
||||||
pub fn new(control: Sender<ControlAction>) -> Self {
|
pub fn new(control: Sender<ControlAction>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -203,13 +211,18 @@ impl SystemControlWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "linux")))]
|
#[cfg(not(feature = "os-controls"))]
|
||||||
impl SystemControlWrapper {
|
impl SystemControlWrapper {
|
||||||
pub fn new(control: Sender<ControlAction>) -> Self {
|
pub fn new(control: Sender<ControlAction>) -> Self {
|
||||||
Self { control: control }
|
Self {
|
||||||
|
control: control,
|
||||||
|
playback_receiver: None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&mut self, _playback: Receiver<PlaybackAction>) {}
|
pub fn init(&mut self, playback: Receiver<PlaybackAction>) {
|
||||||
|
self.playback_receiver = Some(playback);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn exit(self) {}
|
pub fn exit(self) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue