1.0 KiB
1.0 KiB
Sound Bridge Notes
Glitch University uses a host-managed sound system (Howler-based) with string sound keys, for example:
playSound('ui.button_click')playSound('ui.button_hover')
Recommendation
Treat sound as an optional host integration:
- Use a small wrapper function in the component (
safePlaySound) that checks whether a host sound function exists. - No-op when unavailable (standalone dev should still run).
- Keep sound identifiers as strings/constants so they match host definitions.
Example Pattern
type PlaySound = (id: string) => void;
export function safePlaySound(playSound: PlaySound | undefined, id: string) {
try {
playSound?.(id);
} catch {
// Ignore host sound errors in standalone/local mode
}
}
Unknowns to Confirm Later
- How the host exposes
playSoundto glitch-components (prop, context, global import, event bus) - Which sound keys are safe/standardized across experiences
- Whether completion/reward sounds are triggered by host or component