File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 33## 2.3.15
44
55- Organized the FAQ section
6+ - Fixed audio resuming in the web version
67
78## 2.3.14
89
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ async function launchPyxel(params) {
4949 let canvas = await _createScreenElements ( ) ;
5050 let pyodide = await _loadPyodideAndPyxel ( canvas ) ;
5151 _hookFileOperations ( pyodide , params . root || "." ) ;
52+ _resumeAudioOnInput ( ) ;
5253 await _waitForInput ( ) ;
5354 await _executePyxelCommand ( pyodide , params ) ;
5455}
@@ -255,6 +256,18 @@ function _hookFileOperations(pyodide, root) {
255256 } ;
256257}
257258
259+ function _resumeAudioOnInput ( ) {
260+ let audioContext = new ( window . AudioContext || window . webkitAudioContext ) ( ) ;
261+ let resumeAudio = ( ) => {
262+ if ( audioContext . state === "suspended" ) {
263+ audioContext . resume ( ) ;
264+ }
265+ } ;
266+ [ "keydown" , "click" , "touchstart" ] . forEach ( ( event ) =>
267+ document . addEventListener ( event , resumeAudio )
268+ ) ;
269+ }
270+
258271function _isTouchDevice ( ) {
259272 return (
260273 "ontouchstart" in window ||
You can’t perform that action at this time.
0 commit comments