focuz 0.0.1

Lightweight Beautiful Terminal Pomodoro Timer
Documentation
use std::{process, time::Duration};

use rodio::{OutputStream, Source};

const START_SOUND: &[u8] = include_bytes!("../../assets/sounds/start.wav");
const END_SOUND: &[u8] = include_bytes!("../../assets/sounds/end.mp3");

pub async fn play_start_sound() {
    if let Ok((_stream, stream_handle)) = OutputStream::try_default() {
        if let Ok(source) = rodio::Decoder::new(std::io::Cursor::new(START_SOUND)) {
            let _ = stream_handle.play_raw(source.convert_samples());
            tokio::time::sleep(Duration::from_millis(1000)).await;
        }
    }
}

pub async fn play_end_sound() {
    if let Ok((_stream, stream_handle)) = OutputStream::try_default() {
        if let Ok(source) = rodio::Decoder::new(std::io::Cursor::new(END_SOUND)) {
            let _ = stream_handle.play_raw(source.convert_samples());
            tokio::time::sleep(Duration::from_millis(1000)).await;
        }
    }
    process::exit(0);
}