rscenes_raylib_connector/ext/
music.rs1use crate::raudio::RaudioImpl;
2use raylib_ffi::*;
3use std::fmt::Display;
4
5pub trait MusicExt: Sized {
6 fn load(filename: impl Display) -> Result<Self, String>;
8 fn load_from_memory(tpe: impl Display, data: &[u8]) -> Result<Self, String>;
10
11 fn is_ready(self) -> bool;
13 fn unload(self);
15 fn play(self);
17 fn is_playing(self) -> bool;
19 fn update(self);
21 fn stop(self);
23 fn pause(self);
25 fn resume(self);
27 fn seek(self, position: f32);
29 fn set_volume(self, volume: f32);
31 fn set_pitch(self, pitch: f32);
33 fn set_pan(self, pan: f32);
35 fn get_time_length(self) -> f32;
37 fn get_time_played(self) -> f32;
39}
40
41impl MusicExt for Music {
42 fn load(filename: impl Display) -> Result<Self, String> {
43 RaudioImpl::__load_music_stream(filename)
44 }
45
46 fn load_from_memory(tpe: impl Display, data: &[u8]) -> Result<Self, String> {
47 RaudioImpl::__load_music_stream_from_memory(tpe, data)
48 }
49
50 fn is_ready(self) -> bool {
51 RaudioImpl::__is_music_ready(self)
52 }
53
54 fn unload(self) {
55 RaudioImpl::__unload_music_stream(self)
56 }
57
58 fn play(self) {
59 RaudioImpl::__play_music_stream(self)
60 }
61
62 fn is_playing(self) -> bool {
63 RaudioImpl::__is_music_stream_playing(self)
64 }
65
66 fn update(self) {
67 RaudioImpl::__update_music_stream(self)
68 }
69
70 fn stop(self) {
71 RaudioImpl::__stop_music_stream(self)
72 }
73
74 fn pause(self) {
75 RaudioImpl::__pause_music_stream(self)
76 }
77
78 fn resume(self) {
79 RaudioImpl::__resume_music_stream(self)
80 }
81
82 fn seek(self, position: f32) {
83 RaudioImpl::__seek_music_stream(self, position)
84 }
85
86 fn set_volume(self, volume: f32) {
87 RaudioImpl::__set_music_volume(self, volume)
88 }
89
90 fn set_pitch(self, pitch: f32) {
91 RaudioImpl::__set_music_pitch(self, pitch)
92 }
93
94 fn set_pan(self, pan: f32) {
95 RaudioImpl::__set_music_pan(self, pan)
96 }
97
98 fn get_time_length(self) -> f32 {
99 RaudioImpl::__get_music_time_length(self)
100 }
101
102 fn get_time_played(self) -> f32 {
103 RaudioImpl::__get_music_time_played(self)
104 }
105}