import React, { useEffect, useState } from 'react'; import { HMSNotificationTypes, HMSTrackException, HMSTrackExceptionTrackType, useHMSNotifications, } from '@100mslive/react-sdk'; import { Button, Dialog, Text } from '../../..'; // @ts-ignore: No implicit Any import { DialogContent, DialogRow } from '../../primitives/DialogContent'; // @ts-ignore: No implicit Any import { ToastManager } from '../Toast/ToastManager'; const Instruction = ({ description }: { description: string }) => (
  • {description}
  • ); export function DeviceInUseError() { const notification = useHMSNotifications(HMSNotificationTypes.ERROR); const [showDeviceInUseModal, setShowDeviceInUseModal] = useState(false); const [deviceType, setDeviceType] = useState(''); useEffect(() => { const error = notification?.data; if (!error || error.code !== 3003) { return; } const errorTrackExceptionType = (error as HMSTrackException)?.trackType; const hasAudio = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO; const hasVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.VIDEO; const hasAudioVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO_VIDEO; const hasScreen = errorTrackExceptionType === HMSTrackExceptionTrackType.SCREEN; const errorMessage = error?.message; ToastManager.addToast({ title: `Error: ${errorMessage} - ${error?.description}`, action: ( ), }); if (hasAudioVideo) { setDeviceType('camera and microphone'); } else if (hasAudio) { setDeviceType('microphone'); } else if (hasVideo) { setDeviceType('camera'); } else if (hasScreen) { setDeviceType('screen'); } }, [notification]); return ( { setShowDeviceInUseModal(false); }} > We weren't able to access your {deviceType} since it's either in use by another application or is not configured properly. Please follow the following instructions to resolve this issue.
      Privacy and security > Site settings > ${deviceType} and check if your preferred device is selected as default.`} />
    ); }