audio: rename play to play_source and queue to play

This commit is contained in:
Carter Anderson 2020-07-16 14:23:57 -07:00
parent 7bdca4e5f0
commit f546aad7f4
2 changed files with 4 additions and 4 deletions

View file

@ -19,13 +19,13 @@ impl Default for AudioOutput {
}
impl AudioOutput {
pub fn play(&self, audio_source: &AudioSource) {
pub fn play_source(&self, audio_source: &AudioSource) {
let sink = Sink::new(&self.device);
sink.append(Decoder::new(Cursor::new(audio_source.clone())).unwrap());
sink.detach();
}
pub fn queue(&self, audio_source: Handle<AudioSource>) {
pub fn play(&self, audio_source: Handle<AudioSource>) {
self.queue.write().unwrap().push_front(audio_source);
}
@ -36,7 +36,7 @@ impl AudioOutput {
while i < len {
let audio_source_handle = queue.pop_back().unwrap();
if let Some(audio_source) = audio_sources.get(&audio_source_handle) {
self.play(audio_source);
self.play_source(audio_source);
} else {
// audio source hasn't loaded yet. add it back to the queue
queue.push_front(audio_source_handle);

View file

@ -11,5 +11,5 @@ fn setup(asset_server: Res<AssetServer>, audio_output: Res<AudioOutput>) {
let music = asset_server
.load("assets/sounds/Windless Slopes.mp3")
.unwrap();
audio_output.queue(music);
audio_output.play(music);
}