Skip to content

Commit

Permalink
WebGlkOte: Move the creation of the AudioContext to inside init() in …
Browse files Browse the repository at this point in the history
…case it helps with Safari
  • Loading branch information
curiousdannii committed Dec 18, 2024
1 parent 2c60d01 commit 012f916
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/glkote/web/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
super()

this.metrics_calculator = new Metrics(this)
if (typeof AudioContext !== 'undefined') {
this.schannels = new SoundChannelManager(this)
}
this.windows = new Windows(this)
}

Expand Down Expand Up @@ -139,6 +136,11 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
}
}

// Set up sound channels now to try to avoid the autoplaying-without-user input problem
if (typeof AudioContext !== 'undefined') {
this.schannels = new SoundChannelManager(this)
}

// Note that this must be called last as it will result in VM.start() being called
return super.init(options)
}
Expand Down Expand Up @@ -187,7 +189,7 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
'hyperlinks',
'timer',
]
if (this.schannels) {
if (typeof AudioContext !== 'undefined') {
capabilities.push('sounds')
}
return capabilities
Expand Down

0 comments on commit 012f916

Please sign in to comment.