From d46b3388df49da5aa8ce1f52dd2bd19a4c812467 Mon Sep 17 00:00:00 2001 From: PSteinhaus Date: Sat, 18 Sep 2021 10:30:11 +0200 Subject: [PATCH] added link to explanation on soundmixer creation; moved mixer creation in astroblasto to `key_down_event`; --- examples/05_astroblasto.rs | 5 +++-- src/audio.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/05_astroblasto.rs b/examples/05_astroblasto.rs index d0a1471..2c79559 100644 --- a/examples/05_astroblasto.rs +++ b/examples/05_astroblasto.rs @@ -351,8 +351,6 @@ impl MainState { game_over: false, }; - audio::maybe_create_soundmixer(ctx); - Ok(s) } @@ -600,6 +598,9 @@ impl EventHandler for MainState { _keymod: KeyMods, _repeat: bool, ) { + // creating the mixer on user interaction might be necessary for web + audio::maybe_create_soundmixer(ctx); + match keycode { KeyCode::Up => { self.input.yaxis = 1.0; diff --git a/src/audio.rs b/src/audio.rs index 7e85c20..8a25c28 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -92,7 +92,7 @@ impl Source { } /// This function should be called in one of the interaction event callbacks before any usages of audio -/// Because web. +/// Because web: https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices pub fn maybe_create_soundmixer(ctx: &mut Context) { let mut mixer = ctx.audio_context.mixer.borrow_mut(); if mixer.is_none() {