generated from PlexSheep/rs-base
fix(notify): sound did not play
cargo devel CI / cargo CI (push) Failing after 1m15s
Details
cargo devel CI / cargo CI (push) Failing after 1m15s
Details
This commit is contained in:
parent
5e2621e828
commit
a379b921e7
|
@ -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")]
|
||||
|
|
Reference in New Issue