Skip to content

Commit cf56c90

Browse files
committed
Added click to start to appease Chrome, auto enable microphone
1 parent 6413796 commit cf56c90

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/views/Visualizer.vue

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
</div>
3838
</div>
3939
</modal>
40+
<modal :show="!settings.showStart && showStart && !showWelcome">
41+
<div class="vis-start">
42+
<button @click="startVis">click to start</button>
43+
</div>
44+
</modal>
4045
<modal :show="settings.showDonate && showDonate && !showWelcome">
4146
<donate-form class="vis__donate" />
4247
<div class="flex">
@@ -69,6 +74,7 @@ import raVe from '@/js/raVe'
6974
7075
export default {
7176
data: () => ({
77+
acx: null,
7278
analyzer: null,
7379
audio: null,
7480
microphone: null,
@@ -89,6 +95,8 @@ export default {
8995
showWelcome: true,
9096
noMoreWelcome: false,
9197
98+
showStart: true,
99+
92100
userActive: true,
93101
userActiveTO: 0,
94102
@@ -123,6 +131,11 @@ export default {
123131
}
124132
},
125133
134+
startVis() {
135+
if (this.acx.resume) this.acx.resume()
136+
this.showStart = false
137+
},
138+
126139
hideDonate() {
127140
this.showDonate = false
128141
if (this.noMoreDonate) this.stopShowingDonate()
@@ -131,6 +144,7 @@ export default {
131144
hideWelcome() {
132145
this.showWelcome = false
133146
if (this.noMoreWelcome) this.stopShowingWelcome()
147+
this.startVis()
134148
},
135149
136150
displayDonate() {
@@ -172,19 +186,20 @@ export default {
172186
// set up visualizer stuff
173187
this.audio = new Audio()
174188
this.audio.volume = 0.5
175-
const acx = new (window.AudioContext || window.webkitAudioContext)()
176-
const src = acx.createMediaElementSource(this.audio)
177-
src.connect(acx.destination)
189+
this.acx = new (window.AudioContext || window.webkitAudioContext)()
190+
const src = this.acx.createMediaElementSource(this.audio)
191+
src.connect(this.acx.destination)
178192
179-
const pt = acx.createGain()
193+
const pt = this.acx.createGain()
180194
src.connect(pt)
181195
182196
this.playlist = new Playlist(this.audio)
183-
this.microphone = new Microphone(this.audio, acx, pt)
184-
this.analyzer = new AudioAnalyzer(acx, pt)
197+
this.microphone = new Microphone(this.audio, this.acx, pt)
198+
this.analyzer = new AudioAnalyzer(this.acx, pt)
185199
186200
const audio = this.audio
187201
const microphone = this.microphone
202+
this.microphone.toggle()
188203
189204
this.source = { paused: false }
190205
setTimeout(() => {

0 commit comments

Comments
 (0)