maylib 0.2.4

A rust-native raylib alternative with multiple window support
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::core::Maylib;
use rodio::{Decoder, Source};
use std::fs::File;
use std::io::BufReader;

impl Maylib {
    /// Plays the audio file at path
    pub fn play_sound(&mut self, path: &str) {
        // Load the audio
        let file = BufReader::new(File::open(path).expect("File not found"));
        // Decode
        let source = Decoder::new(file).expect("File not valid");
        // And play. It's that shrimple
        self.audio.play_raw(source.convert_samples()).expect("TODO: panic message");
    }
}