fix(notify): sound did not play
cargo devel CI / cargo CI (push) Failing after 1m15s Details

This commit is contained in:
Christoph J. Scherr 2024-07-12 14:06:55 +02:00
parent 5e2621e828
commit a379b921e7
1 changed files with 4 additions and 2 deletions

View File

@ -407,17 +407,19 @@ impl Clock {
Self::beep()?;
#[cfg(feature = "sound")]
{
use rodio::{Decoder, OutputStream, Sink};
trace!("playing bundled sound");
use rodio::{source::Source, Decoder, OutputStream};
// only 30 KiB, so let's just include it in the binary and not worry about reading it
// from the fs and somehow making the file be there
let sound: Cursor<_> = std::io::Cursor::new(include_bytes!("../data/media/alarm.mp3"));
trace!("bundled sound: {sound:X?}");
// Get an output stream handle to the default physical sound device
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let source = Decoder::new(sound).expect("could not load the included sound");
stream_handle.play_raw(source.convert_samples())?; // the sound plays in another thread
let sink = Sink::try_new(&stream_handle).expect("could not create an audio sink");
sink.append(source);
debug!("played bundled sound");
}
#[cfg(feature = "desktop")]