diff options
| author | Teddy Wing | 2018-10-28 19:53:50 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2018-10-28 19:53:50 +0100 | 
| commit | e8ba4dc878a44f14e656664fa2e9d0ea362cbc10 (patch) | |
| tree | 000e1b8467b352f40c15a9502c61f8fad858b5e2 /src/map.rs | |
| parent | eb261f29d0ae15c2f941c2d84972bd321bf764ac (diff) | |
| download | dome-key-map-e8ba4dc878a44f14e656664fa2e9d0ea362cbc10.tar.bz2 | |
Add `play_audio()` function
Create a new function that encapsulates the code we experimented with
for playing audio.
Clean up what we had and handle errors by passing them back in a
`Result`.
This allows us to encapsulate, audio playing so we can do it in a single
action during mode switching.
Diffstat (limited to 'src/map.rs')
| -rw-r--r-- | src/map.rs | 27 | 
1 files changed, 0 insertions, 27 deletions
| @@ -1,10 +1,7 @@  use std::env;  use std::ffi::OsString; -use std::io::BufReader;  use std::process::Command; -use rodio::{self, Source}; -  use {Action, HeadphoneButton, MapAction, MapKind};  use ffi::State;  use sounds; @@ -78,27 +75,3 @@ fn run_action(map_action: &MapAction) {          },      }  } - -#[cfg(test)] -mod tests { -    use super::*; - -    #[test] -    fn play_audio() { -        let mode_activated = include_bytes!("../sounds/activ.wav"); -        // let mut sound = sounds::MODE_ACTIVATED; -        // let mut reader = BufReader::new(sounds::MODE_ACTIVATED); -        let file = ::std::fs::File::open("sounds/activ.wav").unwrap(); -        // let reader = BufReader::new(&mode_activated[..]); -        // let reader = BufReader::new(mode_activated); -        // let reader = BufReader::new(file); -        let reader = ::std::io::Cursor::new(sounds::MODE_ACTIVATED); -let device = rodio::default_output_device().unwrap(); -// let source = rodio::Decoder::new(reader).unwrap(); -// rodio::play_raw(&device, source.convert_samples()); -// ::std::thread::sleep_ms(2000); -let sink = rodio::play_once(&device, reader).unwrap(); -sink.sleep_until_end(); -sink.play(); -    } -} | 
