maylib 0.3.2

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 rodio::{Decoder, Source};
use std::fs::File;
use std::io::BufReader;
use crate::core::MAYLIB;

pub fn play_sound(path: &str) {
    let get = MAYLIB.lock().expect("Should be able to lock");
    // 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
    get.audio
        .play_raw(source.convert_samples())
        .expect("TODO: panic message");
}