maylib 0.2.0

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

impl Maylib {
    pub fn play_sound(&mut self, path: &str) {
        let file = BufReader::new(File::open(path).expect("File not found"));
        // Decode that sound file into a source
        let source = Decoder::new(file).expect("File not valid");
        // Play the sound directly on the device
        self.audio.play_raw(source.convert_samples()).expect("TODO: panic message");
    }
}