import {useEffect, useRef, useState} from 'react' import {VIDEO_QUALITIES, type VideoQuality} from './p2p/settings' import {useNetwork} from './useNetwork' const short = (id: string) => id.slice(0, 8) + '…' // Screen capture is desktop-only in practice; hide the button where the API // doesn't exist (most mobile browsers). const canShareScreen = typeof navigator.mediaDevices?.getDisplayMedia === 'function' const btn: React.CSSProperties = { padding: '0.4rem 1rem', borderRadius: 6, border: '1px solid #888', background: '#fff', cursor: 'pointer', fontSize: '1rem' } const primaryBtn: React.CSSProperties = { ...btn, background: '#1a7f37', borderColor: '#1a7f37', color: '#fff' } const dangerBtn: React.CSSProperties = { ...btn, background: '#c62828', borderColor: '#c62828', color: '#fff' } // Merged into a button's style whenever it is disabled, so the explicit // background colors above don't leave a disabled button looking clickable. const disabledStyle: React.CSSProperties = { opacity: 0.4, cursor: 'not-allowed' } function VideoView({ stream, muted, style }: { stream: MediaStream | null muted: boolean style: React.CSSProperties }) { const ref = useRef(null) useEffect(() => { if (ref.current && ref.current.srcObject !== stream) { ref.current.srcObject = stream } }, [stream]) return