diff --git a/.changeset/fresh-cameras-tell.md b/.changeset/fresh-cameras-tell.md new file mode 100644 index 000000000..b9c5a7c48 --- /dev/null +++ b/.changeset/fresh-cameras-tell.md @@ -0,0 +1,5 @@ +--- +"@livekit/components-react": patch +--- + +Add onDeviceError callback to ControlBar diff --git a/packages/react/etc/components-react.api.md b/packages/react/etc/components-react.api.md index 90b75cec1..eb7c573dd 100644 --- a/packages/react/etc/components-react.api.md +++ b/packages/react/etc/components-react.api.md @@ -186,7 +186,7 @@ export interface ConnectionStatusProps extends React_2.HTMLAttributes { // (undocumented) controls?: ControlBarControls; + // (undocumented) + onDeviceError?: (error: { + source: Track.Source; + error: Error; + }) => void; // @alpha saveUserChoices?: boolean; // (undocumented) diff --git a/packages/react/src/prefabs/ControlBar.tsx b/packages/react/src/prefabs/ControlBar.tsx index 2442e06bc..a6662c321 100644 --- a/packages/react/src/prefabs/ControlBar.tsx +++ b/packages/react/src/prefabs/ControlBar.tsx @@ -25,6 +25,7 @@ export type ControlBarControls = { /** @public */ export interface ControlBarProps extends React.HTMLAttributes { + onDeviceError?: (error: { source: Track.Source; error: Error }) => void; variation?: 'minimal' | 'verbose' | 'textOnly'; controls?: ControlBarControls; /** @@ -56,6 +57,7 @@ export function ControlBar({ variation, controls, saveUserChoices = true, + onDeviceError, ...props }: ControlBarProps) { const [isChatOpen, setIsChatOpen] = React.useState(false); @@ -135,6 +137,7 @@ export function ControlBar({ source={Track.Source.Microphone} showIcon={showIcon} onChange={microphoneOnChange} + onDeviceError={(error) => onDeviceError?.({ source: Track.Source.Microphone, error })} > {showText && 'Microphone'} @@ -148,7 +151,12 @@ export function ControlBar({ )} {visibleControls.camera && (
- + onDeviceError?.({ source: Track.Source.Camera, error })} + > {showText && 'Camera'}
@@ -165,6 +173,7 @@ export function ControlBar({ captureOptions={{ audio: true, selfBrowserSurface: 'include' }} showIcon={showIcon} onChange={onScreenShareChange} + onDeviceError={(error) => onDeviceError?.({ source: Track.Source.ScreenShare, error })} > {showText && (isScreenShareEnabled ? 'Stop screen share' : 'Share screen')}