mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
check if argument of initial-value is a number
This commit is contained in:
parent
8313da522b
commit
1dc99e3a15
2 changed files with 10 additions and 6 deletions
|
@ -43,7 +43,7 @@ cargo build --release
|
||||||
A sample program implementing a headless Spotify Connect receiver is provided.
|
A sample program implementing a headless Spotify Connect receiver is provided.
|
||||||
Once you've built *librespot*, run it using :
|
Once you've built *librespot*, run it using :
|
||||||
```shell
|
```shell
|
||||||
target/release/librespot --username USERNAME --cache CACHEDIR --name DEVICENAME
|
target/release/librespot --username USERNAME --cache CACHEDIR --name DEVICENAME [--initial-volume 20]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Discovery mode
|
## Discovery mode
|
||||||
|
@ -108,4 +108,3 @@ https://gitter.im/sashahilton00/spotify-connect-resources
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Everything in this repository is licensed under the MIT license.
|
Everything in this repository is licensed under the MIT license.
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn setup(args: &[String]) -> Setup {
|
||||||
.optopt("", "backend", "Audio backend to use. Use '?' to list options", "BACKEND")
|
.optopt("", "backend", "Audio backend to use. Use '?' to list options", "BACKEND")
|
||||||
.optopt("", "device", "Audio device to use. Use '?' to list options", "DEVICE")
|
.optopt("", "device", "Audio device to use. Use '?' to list options", "DEVICE")
|
||||||
.optopt("", "mixer", "Mixer to use", "MIXER")
|
.optopt("", "mixer", "Mixer to use", "MIXER")
|
||||||
.optopt("", "initial-volume", "Initial volume in %, once connected", "VOLUME");
|
.optopt("", "initial-volume", "Initial volume in %, once connected (must be from 0 to 100)", "VOLUME");
|
||||||
|
|
||||||
let matches = match opts.parse(&args[1..]) {
|
let matches = match opts.parse(&args[1..]) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
|
@ -136,8 +136,13 @@ fn setup(args: &[String]) -> Setup {
|
||||||
.expect("Invalid mixer");
|
.expect("Invalid mixer");
|
||||||
let initial_volume;
|
let initial_volume;
|
||||||
if matches.opt_present("initial-volume"){
|
if matches.opt_present("initial-volume"){
|
||||||
|
if matches.opt_str("initial-volume").unwrap().parse::<i32>().is_ok(){
|
||||||
initial_volume = matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap()* 0xFFFF as i32 / 100 ;
|
initial_volume = matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap()* 0xFFFF as i32 / 100 ;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
initial_volume = 0x8000 as i32;
|
||||||
|
}
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
initial_volume = 0x8000 as i32;
|
initial_volume = 0x8000 as i32;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue