buf: Vec::new(),
}
}
- fn play_file(&mut self, name: &str, cmd_receiver: &mpsc::Receiver<Command>) {
+ fn play_file(&mut self, name: &str, cmd_receiver: &mpsc::Receiver<Command>, start_time: NATimePoint) {
let ret = File::open(name);
if ret.is_err() {
println!("error opening {}", name);
let mut refill_limit = arate * u32::from(dspec.channels);
let underfill_limit = (arate * u32::from(dspec.channels) / 4).max(block_limit);
+ if start_time != NATimePoint::None {
+ let _ret = decoder.demuxer.seek(start_time);
+ }
+
let mut eof = decoder.refill(&device);
while !eof && device.size() < refill_limit {
eof = decoder.refill(&device);
return;
}
- for arg in args[1..].iter() {
- player.play_file(arg, &cmd_receiver);
- if player.ended {
- break;
- }
+ let mut aiter = args[1..].iter();
+ let mut start_time = NATimePoint::None;
+ while let Some(arg) = aiter.next() {
+ match arg.as_str() {
+ "-start" => {
+ if let Some(arg) = aiter.next() {
+ if let Ok(val) = arg.parse() {
+ start_time = val;
+ } else {
+ println!("invalid time");
+ }
+ } else {
+ println!("argument is required");
+ }
+ },
+ _ => {
+ player.play_file(arg, &cmd_receiver, start_time);
+ if player.ended {
+ break;
+ }
+ start_time = NATimePoint::None;
+ },
+ };
}
cmd_state.restore();