|
"use client" |
|
|
|
import { useEffect, useState } from "react" |
|
import { AudioHeartbeat } from "./audio-heartbeat" |
|
import { VisualHeartbeat } from "./visual-heartbeat" |
|
|
|
export function HeartbeatEffect() { |
|
const [audioSupported, setAudioSupported] = useState<boolean | null>(null) |
|
|
|
useEffect(() => { |
|
|
|
const isAudioSupported = |
|
typeof window !== "undefined" && (window.AudioContext || (window as any).webkitAudioContext) |
|
setAudioSupported(!!isAudioSupported) |
|
}, []) |
|
|
|
|
|
if (audioSupported === null) return null |
|
|
|
|
|
return audioSupported ? <AudioHeartbeat /> : <VisualHeartbeat /> |
|
} |
|
|