Bug 1530220 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Audio elements are not allowed to play on a page that has not been interacted with by the user, and that's fine, but apparently "keyboard interaction" does not count as interaction for this purpose and that's not okay. People who can't use mice should still be able to play web games with sound even though they're navigating purely with a keyboard.

STR:

<html>
  <audio id="clip" src="some-random-file.mp3"></audio>
  <button id="test">play sound</button>
  <script>
    let clip = document.getElementById('clip');
    let btn = document.getElementById('test');
    btn.addEventListener('click', evt => {
      clip.play();
    });
    btn.focus();
  </script>
</html>

load page (which will make sure all the user has to do is press enter), and press enter.

Expected:

The clip plays because the user has interacted with the page.

Actual:

Console error "Autoplay is only allowed when approved by the user, the site is activated by the user, or media is muted."

Additional:

This works 100% fine if the user clicks the button using the mouse, so something's forgetting to record that fact that keyboard interaction is just as valid as mouse interaction.

What do other browsers do:

Edge: plays audio on "enter" from keyboard
Chrome: plays audio on "enter" from keyboard
Audio elements are not allowed to play on a page that has not been interacted with by the user, and that's fine, but apparently "keyboard interaction" does not count as interaction for this purpose and that's not okay. People who can't use mice should still be able to play web games with sound even though they're navigating purely with a keyboard.

STR:

<html>
  <audio id="clip" src="some-random-file.mp3"></audio>
  <button id="test">play sound</button>
  <script>
    let clip = document.getElementById('clip');
    let btn = document.getElementById('test');
    btn.addEventListener('click', evt => {
      clip.play();
    });
    btn.focus();
  </script>
</html>

load page (which will make sure all the user has to do is press enter), and press enter.

Expected:

The clip plays because the user has interacted with the page.

Actual:

Console error "Autoplay is only allowed when approved by the user, the site is activated by the user, or media is muted."

Additional:

This works 100% fine if the user clicks the button using the mouse, so something's forgetting to record the fact that keyboard interaction is just as valid as mouse interaction.

What do other browsers do:

Edge: plays audio on "enter" from keyboard
Chrome: plays audio on "enter" from keyboard

Back to Bug 1530220 Comment 0