feat(04-01): add mute button with CSS, wire audio toggle in main.ts
- Add mute-btn element to index.html outside all screen sections - Add .mute-btn CSS styles (fixed position, bottom-right, circular) - Wire mute button click handler to toggle audioEnabled in Settings - Initialize AudioContext on first user interaction (autoplay policy) - Fix lint issues: import ordering, non-null assertion
This commit is contained in:
+3
-3
@@ -1,5 +1,5 @@
|
||||
import { getSettings } from "../storage/db";
|
||||
import { getDB } from "../app";
|
||||
import { getSettings } from "../storage/db";
|
||||
|
||||
let audioCtx: AudioContext | null = null;
|
||||
|
||||
@@ -83,12 +83,12 @@ export async function playRewardSound(): Promise<void> {
|
||||
const noteDuration = 0.15;
|
||||
const now = ctx.currentTime;
|
||||
|
||||
for (let i = 0; i < notes.length; i++) {
|
||||
for (const [i, freq] of notes.entries()) {
|
||||
const osc = ctx.createOscillator();
|
||||
const gain = ctx.createGain();
|
||||
|
||||
osc.type = "sine";
|
||||
osc.frequency.value = notes[i]!;
|
||||
osc.frequency.value = freq;
|
||||
gain.gain.value = 0.12;
|
||||
|
||||
osc.connect(gain);
|
||||
|
||||
Reference in New Issue
Block a user