1
0
mirror of https://github.com/pavlobu/deskreen.git synced 2025-05-21 09:50:13 -07:00

Merge pull request #96 from pavlobu/flip

add flip video button and 100% video quality by default
This commit is contained in:
Pavlo Buidenkov 2021-02-04 13:44:49 +02:00 committed by GitHub
commit b2ca8a4999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 52 deletions

View File

@ -28,6 +28,7 @@ import { VideoQuality } from '../../features/VideoAutoQualityOptimizer/VideoQual
import handlePlayerToggleFullscreen from './handlePlayerToggleFullscreen';
import initScreenfullOnChange from './initScreenfullOnChange';
import ScreenSharingSource from '../../features/PeerConnection/ScreenSharingSourceEnum';
import { REACT_PLAYER_WRAPPER_ID } from '../../constants/appConstants';
const videoQualityButtonStyle: React.CSSProperties = {
width: '100%',
@ -46,6 +47,8 @@ interface PlayerControlPanelProps {
toaster: undefined | Toaster;
}
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
function PlayerControlPanel(props: PlayerControlPanelProps) {
const {
isPlaying,
@ -62,6 +65,7 @@ function PlayerControlPanel(props: PlayerControlPanelProps) {
const isFullScreenAPIAvailable = useMemo(() => screenfull.isEnabled, []);
const [isFullScreenOn, setIsFullScreenOn] = useState(false);
const [isVideoFlipped, setIsVideoFlipped] = useState(false);
useEffect(() => {
initScreenfullOnChange(setIsFullScreenOn);
@ -71,6 +75,27 @@ function PlayerControlPanel(props: PlayerControlPanelProps) {
handlePlayerToggleFullscreen();
}, []);
const toggleFlipVideo = useCallback(() => {
const videoElement = isSafari
? document.querySelector(`#${REACT_PLAYER_WRAPPER_ID}`)
: document.querySelector(`#${REACT_PLAYER_WRAPPER_ID} > video`);
if (isVideoFlipped) {
// @ts-ignore
videoElement.style.transform = '';
setIsVideoFlipped(false);
} else {
// @ts-ignore
videoElement.style.transform = 'rotateY(180deg)';
setIsVideoFlipped(true);
}
toaster?.show({
icon: 'clean',
intent: Intent.PRIMARY,
message: `Video is flipped horizontally`,
});
}, [isVideoFlipped, toaster]);
return (
<>
<Card elevation={4}>
@ -184,29 +209,34 @@ function PlayerControlPanel(props: PlayerControlPanelProps) {
borderBottom: '1px solid #ffffffa8',
}}
/>
{screenSharingSourceType === ScreenSharingSource.WINDOW ? (
<Tooltip
content="You can't change video quality when sharing a window. You can change quality only when shering entire screen."
position={Position.BOTTOM}
>
<Button minimal disabled>
<Icon icon="cog" color="#A7B6C2" />
</Button>
</Tooltip>
) : (
<Popover
content={
<>
<H5>Video Quality:</H5>
<H5>Video Settings:</H5>
<Divider />
{Object.values(VideoQuality).map(
(q: VideoQuality) => {
<Row>
<Button
icon="key-tab"
minimal
active={isVideoFlipped}
style={videoQualityButtonStyle}
onClick={toggleFlipVideo}
>
Flip
</Button>
</Row>
<Divider />
{Object.values(VideoQuality).map((q: VideoQuality) => {
return (
<Row key={q}>
<Button
minimal
active={selectedVideoQuality === q}
style={videoQualityButtonStyle}
disabled={
screenSharingSourceType ===
ScreenSharingSource.WINDOW
}
onClick={() => {
setVideoQuality(q);
toaster?.show({
@ -220,23 +250,19 @@ function PlayerControlPanel(props: PlayerControlPanelProps) {
</Button>
</Row>
);
}
)}
})}
</>
}
position={Position.BOTTOM}
popoverClassName={Classes.POPOVER_CONTENT_SIZING}
>
<Tooltip
content="Video Quality"
position={Position.BOTTOM}
>
<Tooltip content="Video Quality" position={Position.BOTTOM}>
<Button minimal>
<Icon icon="cog" color="white" />
</Button>
</Tooltip>
</Popover>
)}
<Divider
style={{
height: '20px',

View File

@ -49,7 +49,7 @@ function MainView() {
LoadingSharingIconType
>(LoadingSharingIconEnum.DESKTOP);
const [videoQuality, setVideoQuality] = useState<VideoQuality>(
VideoQuality.Q_AUTO
VideoQuality.Q_100_PERCENT
);
const [peer, setPeer] = useState<undefined | PeerConnection>();