Hiyve Components - v1.0.0
    Preparing search index...
    • Resume an audio context if it is suspended, returning whether it is running afterwards.

      Parameters

      Returns Promise<boolean>

      true when the context is running after the attempt

      Mobile browsers create audio contexts in the suspended state until a user gesture, and resume() outside a gesture may reject or resolve without effect. Call this inside gesture handlers before scheduling audio, and check the result: false means anything scheduled now will be silent.

      button.onclick = async () => {
      if (await ensureAudioContextRunning(ctx)) {
      playChime(ctx);
      }
      };