|
1 | 1 | import { useEffect, useRef } from "react";
|
2 |
| -import { Spinner, match, unreachable, useColorScheme } from "@opencast/appkit"; |
3 |
| -import { useTranslation } from "react-i18next"; |
| 2 | +import { Spinner, WithTooltip, match, unreachable, useColorScheme } from "@opencast/appkit"; |
| 3 | +import { Trans, useTranslation } from "react-i18next"; |
| 4 | +import { LuInfo, LuVolume2, LuVolumeX } from "react-icons/lu"; |
4 | 5 |
|
5 | 6 | import { COLORS, dimensionsOf } from "../../util";
|
6 |
| -import { StreamSettings } from "./prefs"; |
7 |
| -import { Input } from "."; |
8 | 7 | import { VideoBox, useVideoBoxResize } from "../../ui/VideoBox";
|
9 | 8 | import { ErrorBox } from "../../ui/ErrorBox";
|
| 9 | +import { StreamSettings } from "./prefs"; |
| 10 | +import { Input } from "."; |
10 | 11 |
|
11 | 12 |
|
12 | 13 |
|
@@ -63,7 +64,10 @@ const StreamPreview: React.FC<{ input: Input }> = ({ input }) => {
|
63 | 64 | },
|
64 | 65 | }}>
|
65 | 66 | <PreviewVideo input={input} />
|
66 |
| - {input.stream && <StreamSettings isDesktop={input.isDesktop} stream={input.stream} />} |
| 67 | + {input.stream && <> |
| 68 | + {input.isDesktop && <DisplayAudioInfo stream={input.stream} />} |
| 69 | + <StreamSettings isDesktop={input.isDesktop} stream={input.stream} /> |
| 70 | + </>} |
67 | 71 | </div>
|
68 | 72 | );
|
69 | 73 | };
|
@@ -145,3 +149,49 @@ const PreviewVideo: React.FC<{ input: Input }> = ({ input }) => {
|
145 | 149 | </div>
|
146 | 150 | );
|
147 | 151 | };
|
| 152 | + |
| 153 | +export const DisplayAudioInfo: React.FC<{ stream: MediaStream }> = ({ stream }) => { |
| 154 | + const hasAudio = stream.getAudioTracks().length; |
| 155 | + |
| 156 | + return ( |
| 157 | + <div css={{ |
| 158 | + position: "absolute", |
| 159 | + top: 8, |
| 160 | + right: 8, |
| 161 | + }}> |
| 162 | + <WithTooltip |
| 163 | + placement="top" |
| 164 | + tooltip={ |
| 165 | + <Trans i18nKey={ |
| 166 | + `steps.video.${hasAudio ? "display-audio-shared" : "display-audio-not-shared"}` |
| 167 | + }> |
| 168 | + <strong>Note:</strong> Explanation. |
| 169 | + </Trans> |
| 170 | + } |
| 171 | + > |
| 172 | + <div css={{ ...OVERLAY_STYLE, fontSize: 15 }}> |
| 173 | + <LuInfo /> {hasAudio ? <LuVolume2 /> : <LuVolumeX />} |
| 174 | + </div> |
| 175 | + </WithTooltip> |
| 176 | + </div> |
| 177 | + ); |
| 178 | +}; |
| 179 | + |
| 180 | +export const OVERLAY_STYLE = { |
| 181 | + border: "none", |
| 182 | + display: "inline-block", |
| 183 | + backgroundColor: "rgba(0, 0, 0, 0.3)", |
| 184 | + color: "white", |
| 185 | + padding: 8, |
| 186 | + backdropFilter: "invert(0.3) blur(4px)", |
| 187 | + lineHeight: 0, |
| 188 | + borderRadius: 10, |
| 189 | + cursor: "pointer", |
| 190 | + "&:hover, &:focus-visible": { |
| 191 | + backgroundColor: "rgba(0, 0, 0, 0.5)", |
| 192 | + }, |
| 193 | + "&:focus-visible": { |
| 194 | + outline: "5px dashed white", |
| 195 | + outlineOffset: -2.5, |
| 196 | + }, |
| 197 | +}; |
0 commit comments