Using Chrome 103.0.5060.114.
Even if I do the following to prevent the error Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. on two images that play a sound when hovered:
$('#prevImage, #nextImage').hover(_ => {
// Check modern Chrome autoplay permission on first interaction against getting an error
if ((new AudioContext()).state == 'running') {
SoundNames.MAP_HOVER.play()
}
})
Browser produces the warning The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.
How could I check if the Audio element is ready without a warning? (SoundNames.MAP_HOVER is an Audio object)