test: changed to sinks and fuzzy search
This commit is contained in:
parent
20461a4529
commit
589fa62e73
1 changed files with 11 additions and 8 deletions
19
src/main.rs
19
src/main.rs
|
@ -1,4 +1,4 @@
|
|||
use rodio::{source::Source, Decoder, OutputStream};
|
||||
use rodio::{source::Source, Decoder, OutputStream, Sink};
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::path::PathBuf;
|
||||
|
@ -68,13 +68,13 @@ fn main() {
|
|||
}
|
||||
|
||||
let test_tag = PartialTag {
|
||||
title: Some("Clap On, Clap Off".to_string()),
|
||||
title: Some("%bees%".to_string()),
|
||||
..PartialTag::default()
|
||||
};
|
||||
|
||||
let test_file = dbo
|
||||
.get(&DatabaseRequest {
|
||||
search_type: db_operations::SearchType::Where,
|
||||
search_type: db_operations::SearchType::Like,
|
||||
search_tag: test_tag,
|
||||
})
|
||||
.unwrap()
|
||||
|
@ -82,16 +82,19 @@ fn main() {
|
|||
|
||||
// Get a output stream handle to the default physical sound device
|
||||
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
||||
// open an audio sink
|
||||
let sink = Sink::try_new(&stream_handle).unwrap();
|
||||
// Load a sound from a file, using a path relative to Cargo.toml
|
||||
let file = BufReader::new(File::open(test_file[0].path.clone()).unwrap());
|
||||
// Decode that sound file into a source
|
||||
let source = Decoder::new(file).unwrap();
|
||||
sink.append(source);
|
||||
// Play the sound directly on the device
|
||||
stream_handle.play_raw(source.convert_samples()).unwrap();
|
||||
|
||||
// The sound plays in a separate audio thread,
|
||||
// so we need to keep the main thread alive while it's playing.
|
||||
std::thread::sleep(std::time::Duration::from_secs(35));
|
||||
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||
sink.pause();
|
||||
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||
sink.play();
|
||||
sink.sleep_until_end();
|
||||
|
||||
println!("{:?}", cli);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue