copy / v86

x86 PC emulator and x86-to-wasm JIT, running in the browser
https://copy.sh/v86/
BSD 2-Clause "Simplified" License
19.87k stars 1.41k forks source link

audio is sometimes blocked by the browser's autoplay detection #1121

Closed jeffy79 closed 1 month ago

jeffy79 commented 3 months ago

this is on fire fox but for some reason the start up sound on windows 2000 it has sound and then for some reason on some days it does not have sound when i use it is there a fix for that ?

copy commented 3 months ago

The problem is probably this:

The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page

It happens when you open the page without a "gesture" (e.g. by copy-pasting the url). The browser tries to prevent audio autoplaying.

A fix would be to resume the audio context on the next event (e.g. click or key press). A PR would be welcome.

dylaniscool54 commented 2 months ago

image

https://developer.chrome.com/blog/autoplay/#webaudio

you need to create some sort of start button on your webpage before v86 is loaded.

copy commented 2 months ago

you need to create some sort of start button on your webpage before v86 is loaded.

My suggestion would be to do it when clicking on the screen to lock the mouse.