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::fs::File;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -68,13 +68,13 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let test_tag = PartialTag {
|
let test_tag = PartialTag {
|
||||||
title: Some("Clap On, Clap Off".to_string()),
|
title: Some("%bees%".to_string()),
|
||||||
..PartialTag::default()
|
..PartialTag::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let test_file = dbo
|
let test_file = dbo
|
||||||
.get(&DatabaseRequest {
|
.get(&DatabaseRequest {
|
||||||
search_type: db_operations::SearchType::Where,
|
search_type: db_operations::SearchType::Like,
|
||||||
search_tag: test_tag,
|
search_tag: test_tag,
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -82,16 +82,19 @@ fn main() {
|
||||||
|
|
||||||
// Get a output stream handle to the default physical sound device
|
// Get a output stream handle to the default physical sound device
|
||||||
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
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
|
// 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());
|
let file = BufReader::new(File::open(test_file[0].path.clone()).unwrap());
|
||||||
// Decode that sound file into a source
|
// Decode that sound file into a source
|
||||||
let source = Decoder::new(file).unwrap();
|
let source = Decoder::new(file).unwrap();
|
||||||
|
sink.append(source);
|
||||||
// Play the sound directly on the device
|
// Play the sound directly on the device
|
||||||
stream_handle.play_raw(source.convert_samples()).unwrap();
|
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||||
|
sink.pause();
|
||||||
// The sound plays in a separate audio thread,
|
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||||
// so we need to keep the main thread alive while it's playing.
|
sink.play();
|
||||||
std::thread::sleep(std::time::Duration::from_secs(35));
|
sink.sleep_until_end();
|
||||||
|
|
||||||
println!("{:?}", cli);
|
println!("{:?}", cli);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue