mirror of
https://github.com/talwat/lowfi
synced 2025-01-12 19:31:54 +00:00
feat: add --pause flag
This commit is contained in:
parent
6b157dd457
commit
c7d46e9872
@ -17,6 +17,10 @@ struct Args {
|
||||
#[clap(long, short)]
|
||||
minimalist: bool,
|
||||
|
||||
/// Whether to start lowfi paused
|
||||
#[clap(long, short)]
|
||||
paused: bool,
|
||||
|
||||
/// The command that was ran.
|
||||
/// This is [None] if no command was specified.
|
||||
#[command(subcommand)]
|
||||
|
@ -74,7 +74,7 @@ pub async fn play(args: Args) -> eyre::Result<()> {
|
||||
let properties = InitialProperties::load().await?;
|
||||
|
||||
let (tx, rx) = mpsc::channel(8);
|
||||
let player = Arc::new(Player::new(!args.alternate).await?);
|
||||
let player = Arc::new(Player::new(!args.alternate, &args).await?);
|
||||
let ui = task::spawn(ui::start(Arc::clone(&player), tx.clone(), args));
|
||||
|
||||
tx.send(Messages::Init).await?;
|
||||
|
@ -21,6 +21,7 @@ use tokio::{
|
||||
use crate::{
|
||||
play::InitialProperties,
|
||||
tracks::{DecodedTrack, Track, TrackInfo},
|
||||
Args,
|
||||
};
|
||||
|
||||
pub mod downloader;
|
||||
@ -141,7 +142,7 @@ impl Player {
|
||||
/// `silent` can control whether alsa's output should be redirected,
|
||||
/// but this option is only applicable on Linux, as on MacOS & Windows
|
||||
/// it will never be silent.
|
||||
pub async fn new(silent: bool) -> eyre::Result<Self> {
|
||||
pub async fn new(silent: bool, args: &Args) -> eyre::Result<Self> {
|
||||
let (_stream, handle) = if silent && cfg!(target_os = "linux") {
|
||||
Self::silent_get_output_stream()?
|
||||
} else {
|
||||
@ -149,6 +150,9 @@ impl Player {
|
||||
};
|
||||
|
||||
let sink = Sink::try_new(&handle)?;
|
||||
if args.paused {
|
||||
sink.pause();
|
||||
}
|
||||
|
||||
let player = Self {
|
||||
tracks: RwLock::new(VecDeque::with_capacity(5)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user