mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
audio: rename play
to play_source
and queue
to play
This commit is contained in:
parent
7bdca4e5f0
commit
f546aad7f4
2 changed files with 4 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue