diff --git a/src/components/gameboy.tsx b/src/components/gameboy.tsx index 50ba4b08b..e19977730 100644 --- a/src/components/gameboy.tsx +++ b/src/components/gameboy.tsx @@ -19,6 +19,7 @@ const Gameboy: React.FC = ({ className, src, aspect = 'normal', onFocu const canvas = useRef(null); const [paused, setPaused] = useState(false); + const [muted, setMuted] = useState(true); async function init() { await WasmBoy.config(WasmBoyOptions, canvas.current!); @@ -52,6 +53,11 @@ const Gameboy: React.FC = ({ className, src, aspect = 'normal', onFocu const togglePaused = () => paused ? play() : pause(); + const unmute = async () => { + await WasmBoy.resumeAudioContext(); + setMuted(false); + }; + useEffect(() => { init(); @@ -75,12 +81,17 @@ const Gameboy: React.FC = ({ className, src, aspect = 'normal', onFocu {...rest} /> -
+
+
); @@ -89,7 +100,7 @@ const Gameboy: React.FC = ({ className, src, aspect = 'normal', onFocu const WasmBoyOptions = { headless: false, useGbcWhenOptional: true, - isAudioEnabled: false, + isAudioEnabled: true, frameSkip: 1, audioBatchProcessing: true, timersBatchProcessing: false,