Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/fireworks-js/src/fireworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export class Fireworks {
}

private initTrace(): void {
this.sound.init();
if (this.waitStopRaf) return

const { delay, mouse } = this.opts
Expand Down
4 changes: 1 addition & 3 deletions packages/fireworks-js/src/sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class Sound {
private onInit = false

constructor(private readonly options: Options) {
this.init()
}

private get isEnabled() {
Expand Down Expand Up @@ -49,6 +48,7 @@ export class Sound {
}

play(): void {
this.init()
if (this.isEnabled && this.buffers.length) {
const bufferSource = this.audioContext.createBufferSource()
const soundBuffer = this.buffers[randomInt(0, this.buffers.length - 1)]!
Expand All @@ -62,8 +62,6 @@ export class Sound {
volume.connect(this.audioContext.destination)
bufferSource.connect(volume)
bufferSource.start(0)
} else {
this.init()
}
}
}