Skip to content

Commit 012f916

Browse files
committed
WebGlkOte: Move the creation of the AudioContext to inside init() in case it helps with Safari
1 parent 2c60d01 commit 012f916

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/glkote/web/web.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
5757
super()
5858

5959
this.metrics_calculator = new Metrics(this)
60-
if (typeof AudioContext !== 'undefined') {
61-
this.schannels = new SoundChannelManager(this)
62-
}
6360
this.windows = new Windows(this)
6461
}
6562

@@ -139,6 +136,11 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
139136
}
140137
}
141138

139+
// Set up sound channels now to try to avoid the autoplaying-without-user input problem
140+
if (typeof AudioContext !== 'undefined') {
141+
this.schannels = new SoundChannelManager(this)
142+
}
143+
142144
// Note that this must be called last as it will result in VM.start() being called
143145
return super.init(options)
144146
}
@@ -187,7 +189,7 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
187189
'hyperlinks',
188190
'timer',
189191
]
190-
if (this.schannels) {
192+
if (typeof AudioContext !== 'undefined') {
191193
capabilities.push('sounds')
192194
}
193195
return capabilities

0 commit comments

Comments
 (0)