1use rodio::{Decoder, OutputStream, Sink};
2use std::fs::File;
3use std::io::BufReader;
4
5pub struct Adhan {
6 pub file: String,
7}
8
9impl Adhan {
10 pub fn new(file: String) -> Self {
11 Self { file }
12 }
13
14 pub fn play(&self) {
15 let (_stream, stream_handle) = OutputStream::try_default().unwrap();
16 let sink = Sink::try_new(&stream_handle).unwrap();
17
18 sink.set_volume(1_f32);
19
20 let file = BufReader::new(File::open(&self.file).unwrap());
21 let source = Decoder::new(file).unwrap();
22
23 sink.append(source);
24 sink.sleep_until_end();
25 }
26}