mdn / webaudio-examples

Code examples that accompany the MDN Web Docs pages relating to Web Audio.
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
Creative Commons Zero v1.0 Universal
1.28k stars 433 forks source link

Fixes mdn/content#9451 - Thanks @DrTechDaddy #54

Closed himanshugarg closed 2 years ago

himanshugarg commented 3 years ago

See https://github.com/mdn/content/issues/9451

The sequence Create context; Suspend context; Stop context; leaves the label of the susresBtn as Resume context

The proposed fix refreshes the label on Start

sideshowbarker commented 2 years ago

@Rumyra @dipikabh This PR is ready to be merged but I can’t merge it myself because I don’t have merge permissions for this repo.

Rumyra commented 2 years ago

@teoli2003 was this resolved when you modernised the code examples?

teoli2003 commented 2 years ago

Yes, though I put the label change inside the stop button click event handler:

      // Close the audiocontext
      stopBtn.onclick = () => {
        audioCtx.close().then(() => {
          startBtn.removeAttribute("disabled");
          susresBtn.setAttribute("disabled", "disabled");
          // Reset the text of the suspend/resume toggle:
          susresBtn.textContent = "Suspend context";
          stopBtn.setAttribute("disabled", "disabled");
        });
      };
Rumyra commented 2 years ago

@himanshugarg thanks so much for your fix and sorry for taking so long to get to it. It seems some work @teoli2003 did recently to update these examples has fixed the issue. In which case we can close this pr and the associated issue. Thanks again for the contribution 👍