Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] custom screen share #1020

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions 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 @@ -173,6 +175,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 variation="minimal" controls={{ chat: true, settings: !!SettingsComponent }} onScreenShareClick={onScreenShareClick} />
</div>
<Chat
style={{ display: widgetState.showChat ? 'grid' : 'none' }}
Expand Down
Loading