Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/menu_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ pub async fn display_menu(config_path: &PathBuf) {
let term_height = get_terminal_height() as usize;
let display_height = term_height.saturating_sub(3);

if config.window_title_support {
if let Some(title) = &config.window_title {
set_window_title(title);
}
if config.window_title_support
&& let Some(title) = &config.window_title
{
set_window_title(title);
}

clear_screen();
Expand Down
9 changes: 5 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rodio::{Decoder, OutputStream, Sink};
use rodio::{Decoder, OutputStreamBuilder, Sink};
use std::fs::File;
use std::io::{BufReader, Write, stdin, stdout};
use std::path::PathBuf;
Expand Down Expand Up @@ -40,16 +40,17 @@ pub async fn play_sound(file_path: PathBuf) {
let file_path = file_path.clone(); // Cloning the PathBuf to be owned by the closure
task::spawn_blocking(move || {
// Spawning a blocking task
match OutputStream::try_default() {
Ok((_stream, stream_handle)) => {

match OutputStreamBuilder::open_default_stream() {
Ok(stream_handle) => {
// Trying to get the default audio output stream
match File::open(&file_path) {
Ok(file) => {
// Trying to open the audio file
match Decoder::new(BufReader::new(file)) {
Ok(source) => {
// Trying to decode the audio file
let sink = Sink::try_new(&stream_handle).unwrap(); // Creating a sink for the audio stream
let sink = Sink::connect_new(stream_handle.mixer()); // Creating a sink for the audio stream
sink.append(source); // Appending the audio source to the sink
sink.sleep_until_end(); // Sleeping until the audio playback ends
}
Expand Down
Loading