mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-06 03:50:06 +02:00
Add a autoplay
option flag
This commit is contained in:
parent
ba2639d1df
commit
b3c9744b29
3 changed files with 35 additions and 17 deletions
22
src/main.rs
22
src/main.rs
|
@ -4,18 +4,18 @@ extern crate getopts;
|
|||
extern crate librespot;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate hex;
|
||||
extern crate rpassword;
|
||||
extern crate sha1;
|
||||
extern crate tokio_core;
|
||||
extern crate tokio_io;
|
||||
extern crate tokio_process;
|
||||
extern crate tokio_signal;
|
||||
extern crate url;
|
||||
extern crate sha1;
|
||||
extern crate hex;
|
||||
|
||||
use sha1::{Sha1, Digest};
|
||||
use futures::sync::mpsc::UnboundedReceiver;
|
||||
use futures::{Async, Future, Poll, Stream};
|
||||
use sha1::{Digest, Sha1};
|
||||
use std::env;
|
||||
use std::io::{self, stderr, Write};
|
||||
use std::mem;
|
||||
|
@ -188,6 +188,11 @@ fn setup(args: &[String]) -> Setup {
|
|||
"",
|
||||
"linear-volume",
|
||||
"increase volume linear instead of logarithmic.",
|
||||
)
|
||||
.optflag(
|
||||
"",
|
||||
"autoplay",
|
||||
"autoplay similar songs when your music ends.",
|
||||
);
|
||||
|
||||
let matches = match opts.parse(&args[1..]) {
|
||||
|
@ -249,7 +254,8 @@ fn setup(args: &[String]) -> Setup {
|
|||
panic!("Initial volume must be in the range 0-100");
|
||||
}
|
||||
(volume as i32 * 0xFFFF / 100) as u16
|
||||
}).or_else(|| cache.as_ref().and_then(Cache::volume))
|
||||
})
|
||||
.or_else(|| cache.as_ref().and_then(Cache::volume))
|
||||
.unwrap_or(0x8000);
|
||||
|
||||
let zeroconf_port = matches
|
||||
|
@ -334,6 +340,7 @@ fn setup(args: &[String]) -> Setup {
|
|||
device_type: device_type,
|
||||
volume: initial_volume,
|
||||
linear_volume: matches.opt_present("linear-volume"),
|
||||
autoplay: matches.opt_present("autoplay"),
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -503,13 +510,14 @@ impl Future for Main {
|
|||
if let Some(ref program) = self.player_event_program {
|
||||
let child = run_program_on_events(event, program)
|
||||
.expect("program failed to start")
|
||||
.map(|status| if !status.success() {
|
||||
error!("child exited with status {:?}", status.code());
|
||||
.map(|status| {
|
||||
if !status.success() {
|
||||
error!("child exited with status {:?}", status.code());
|
||||
}
|
||||
})
|
||||
.map_err(|e| error!("failed to wait on child process: {}", e));
|
||||
|
||||
self.handle.spawn(child);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue