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