use crate::{dx::*, ext::tdx::*};
pub struct Music {
pub d: bool,
pub h: i32
}
impl Tr for Music {
fn as_music(&self) -> Music { Music{d: false, h: self.h} }
fn handle(&self) -> i32 { self.h }
fn dispose(&mut self) {
if self.d && self.h != 0 {
unsafe { DeleteMusicMem(self.h); }
self.h = 0;
}
}
}
impl Drop for Music {
fn drop(&mut self) { self.dispose(); }
}
impl Music {
pub fn load_mem(n: &String) -> Self {
Music{d: true, h: unsafe { LoadMusicMem(n.as_ptr()) } }
}
pub fn volume(&self, v: i32) { unsafe { SetVolumeMusicMem(v, self.h); } }
pub fn stop(&self) { unsafe { StopMusicMem(self.h); } }
pub fn play(&self, t: i32) { unsafe { PlayMusicMem(self.h, t); } }
}