22 lines
617 B
TypeScript
22 lines
617 B
TypeScript
// components/ui/videoPolicy.ts
|
|
export const DEFAULT_INLINE_MUTED = true
|
|
export const DEFAULT_PLAYER_START_MUTED = false
|
|
|
|
export function applyInlineVideoPolicy(
|
|
el: HTMLVideoElement | null,
|
|
opts?: { muted?: boolean }
|
|
) {
|
|
if (!el) return
|
|
const muted = opts?.muted ?? DEFAULT_INLINE_MUTED
|
|
|
|
// Autoplay klappt am zuverlässigsten mit muted + playsInline
|
|
el.muted = muted
|
|
// @ts-ignore (Safari)
|
|
el.defaultMuted = muted
|
|
el.playsInline = true
|
|
|
|
// iOS/Safari: Attribute "present" ist entscheidend (nicht "true"/"false")
|
|
el.setAttribute('playsinline', '')
|
|
el.setAttribute('webkit-playsinline', '')
|
|
}
|