Skip to content

Commit

Permalink
Activate speaker view when screensharing, even while in PiP
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Perez <60019601+josh-signal@users.noreply.github.com>
  • Loading branch information
automated-signal and josh-signal committed Oct 7, 2021
1 parent da8918d commit b6c7c19
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions ts/components/CallManager.tsx
Expand Up @@ -271,6 +271,7 @@ const ActiveCallManager: React.FC<ActiveCallManagerPropsType> = ({
setLocalPreview={setLocalPreview}
setRendererCanvas={setRendererCanvas}
togglePip={togglePip}
toggleSpeakerView={toggleSpeakerView}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions ts/components/CallingPip.stories.tsx
Expand Up @@ -66,6 +66,7 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
setLocalPreview: action('set-local-preview'),
setRendererCanvas: action('set-renderer-canvas'),
togglePip: action('toggle-pip'),
toggleSpeakerView: action('toggleSpeakerView'),
});

const story = storiesOf('Components/CallingPip', module);
Expand Down
9 changes: 9 additions & 0 deletions ts/components/CallingPip.tsx
Expand Up @@ -13,6 +13,7 @@ import {
SetRendererCanvasType,
} from '../state/ducks/calling';
import { missingCaseError } from '../util/missingCaseError';
import { useActivateSpeakerViewOnPresenting } from '../hooks/useActivateSpeakerViewOnPresenting';

enum PositionMode {
BeingDragged,
Expand Down Expand Up @@ -58,6 +59,7 @@ export type PropsType = {
setLocalPreview: (_: SetLocalPreviewType) => void;
setRendererCanvas: (_: SetRendererCanvasType) => void;
togglePip: () => void;
toggleSpeakerView: () => void;
};

const PIP_HEIGHT = 156;
Expand All @@ -75,6 +77,7 @@ export const CallingPip = ({
setLocalPreview,
setRendererCanvas,
togglePip,
toggleSpeakerView,
}: PropsType): JSX.Element | null => {
const videoContainerRef = React.useRef<null | HTMLDivElement>(null);
const localVideoRef = React.useRef(null);
Expand All @@ -86,6 +89,12 @@ export const CallingPip = ({
offsetY: PIP_TOP_MARGIN,
});

useActivateSpeakerViewOnPresenting(
activeCall.remoteParticipants,
activeCall.isInSpeakerView,
toggleSpeakerView
);

React.useEffect(() => {
setLocalPreview({ element: localVideoRef });
}, [setLocalPreview]);
Expand Down

0 comments on commit b6c7c19

Please sign in to comment.