Drump Machine - Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()

Hi, Campers.
I've got a problem with test case 6, and playing audio. I nested the `audio` teg inside a `button` and when I click the button it shoul play that audio.

Everything seams to work well, but test doesn’t pass and in the console I receve an error:

“Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()”

I’ve foloved the error link and made some research, but I steel cannot understand what is the problem.
Thamks a lot.
/p>

User Story #6 is about handling key presses. I only see code for handling mouse events. Do you have code that handles keyboard inputs?

User Story #6: When I press the trigger key associated with each .drum-pad, the audio clip contained in its child audio element should be triggered (e.g. pressing the Q key should trigger the drum pad which contains the string “Q”, pressing the W key should trigger the drum pad which contains the string “W”, etc.).


BTW. The error is (almost certainly) not related to the test failing. The error is caused by the test calling .pause() and the Chrome implementation of .play() returning a Promise. As far as I know, it’s only a problem in Chrome/Chromium (it’s not like I have tested it in all browsers), Firefox does not throw (does follow the specs for play returning a Promise). Not sure what the difference is.

I’m not even sure you can do anything about it in your code, I think the test would need to be updated. It happens in the 25 + 5 Clock project as well, but there you can actually control how pause is called. I did find a solution to it in that project but it was kind of weird.

1 Like

Thank you a lot!
I think I need to redesign my code. :sweat_smile: