Skip to content

Commit

Permalink
[chore] custom screen share
Browse files Browse the repository at this point in the history
  • Loading branch information
showonne committed Oct 30, 2024
1 parent 3e7bd24 commit 87065d9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
12 changes: 7 additions & 5 deletions packages/core/src/components/mediaToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ export function setupMediaToggle<T extends ToggleSource>(
);
return localParticipant.isMicrophoneEnabled;
case Track.Source.ScreenShare:
await localParticipant.setScreenShareEnabled(
forceState ?? !localParticipant.isScreenShareEnabled,
captureOptions as ScreenShareCaptureOptions,
publishOptions,
);
// await localParticipant.setScreenShareEnabled(
// forceState ?? !localParticipant.isScreenShareEnabled,
// captureOptions as ScreenShareCaptureOptions,
// publishOptions,
// );
console.warn('do nothing, use custom screen share picker.');

return localParticipant.isScreenShareEnabled;
default:
throw new TypeError('Tried to toggle unsupported source');
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/controls/TrackToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface TrackToggleProps<T extends ToggleSource>
captureOptions?: CaptureOptionsBySource<T>;
publishOptions?: TrackPublishOptions;
onDeviceError?: (error: Error) => void;
onClick?: (evt: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/prefabs/ControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface ControlBarProps extends React.HTMLAttributes<HTMLDivElement> {
* @alpha
*/
saveUserChoices?: boolean;
onScreenShareClick?: (evt: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
}

/**
Expand All @@ -58,6 +59,7 @@ export function ControlBar({
controls,
saveUserChoices = true,
onDeviceError,
onScreenShareClick,
...props
}: ControlBarProps) {
const [isChatOpen, setIsChatOpen] = React.useState(false);
Expand Down Expand Up @@ -93,7 +95,8 @@ export function ControlBar({
[variation],
);
const showText = React.useMemo(
() => variation === 'textOnly' || variation === 'verbose',
// () => variation === 'textOnly' || variation === 'verbose',
() => false,
[variation],
);

Expand Down Expand Up @@ -173,6 +176,7 @@ export function ControlBar({
captureOptions={{ audio: true, selfBrowserSurface: 'include' }}
showIcon={showIcon}
onChange={onScreenShareChange}
onClick={onScreenShareClick}
onDeviceError={(error) => onDeviceError?.({ source: Track.Source.ScreenShare, error })}
>
{showText && (isScreenShareEnabled ? 'Stop screen share' : 'Share screen')}
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/prefabs/VideoConference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useWarnAboutMissingStyles } from '../hooks/useWarnAboutMissingStyles';
*/
export interface VideoConferenceProps extends React.HTMLAttributes<HTMLDivElement> {
chatMessageFormatter?: MessageFormatter;
onScreenShareClick?: (evt: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
chatMessageEncoder?: MessageEncoder;
chatMessageDecoder?: MessageDecoder;
/** @alpha */
Expand Down Expand Up @@ -58,6 +59,7 @@ export function VideoConference({
chatMessageDecoder,
chatMessageEncoder,
SettingsComponent,
onScreenShareClick,
...props
}: VideoConferenceProps) {
const [widgetState, setWidgetState] = React.useState<WidgetState>({
Expand Down Expand Up @@ -155,7 +157,7 @@ export function VideoConference({
</FocusLayoutContainer>
</div>
)}
<ControlBar controls={{ chat: true, settings: !!SettingsComponent }} />
<ControlBar controls={{ chat: true, settings: !!SettingsComponent }} onScreenShareClick={onScreenShareClick} />
</div>
<Chat
style={{ display: widgetState.showChat ? 'grid' : 'none' }}
Expand Down

0 comments on commit 87065d9

Please sign in to comment.