Add screen-sharing volume control
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
@@ -121,6 +121,15 @@ export const VideoTile = forwardRef<HTMLDivElement, Props>(
|
|||||||
|
|
||||||
const toolbarButtons: JSX.Element[] = [];
|
const toolbarButtons: JSX.Element[] = [];
|
||||||
if (!sfuParticipant.isLocal) {
|
if (!sfuParticipant.isLocal) {
|
||||||
|
toolbarButtons.push(
|
||||||
|
<AudioButton
|
||||||
|
key="localVolume"
|
||||||
|
className={styles.button}
|
||||||
|
volume={(sfuParticipant as RemoteParticipant).getVolume() ?? 0}
|
||||||
|
onPress={onOptionsPress}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
if (content === TileContent.ScreenShare) {
|
if (content === TileContent.ScreenShare) {
|
||||||
toolbarButtons.push(
|
toolbarButtons.push(
|
||||||
<FullscreenButton
|
<FullscreenButton
|
||||||
@@ -130,16 +139,6 @@ export const VideoTile = forwardRef<HTMLDivElement, Props>(
|
|||||||
onPress={onFullscreen}
|
onPress={onFullscreen}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
// Due to the LK SDK this sadly only works for user-media atm
|
|
||||||
toolbarButtons.push(
|
|
||||||
<AudioButton
|
|
||||||
key="localVolume"
|
|
||||||
className={styles.button}
|
|
||||||
volume={(sfuParticipant as RemoteParticipant).getVolume() ?? 0}
|
|
||||||
onPress={onOptionsPress}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,29 +16,36 @@ limitations under the License.
|
|||||||
|
|
||||||
import React, { ChangeEvent, useState } from "react";
|
import React, { ChangeEvent, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { RemoteParticipant } from "livekit-client";
|
import { RemoteParticipant, Track } from "livekit-client";
|
||||||
|
|
||||||
import { FieldRow } from "../input/Input";
|
import { FieldRow } from "../input/Input";
|
||||||
import { Modal } from "../Modal";
|
import { Modal } from "../Modal";
|
||||||
import styles from "./VideoTileSettingsModal.module.css";
|
import styles from "./VideoTileSettingsModal.module.css";
|
||||||
import { VolumeIcon } from "../button/VolumeIcon";
|
import { VolumeIcon } from "../button/VolumeIcon";
|
||||||
import { ItemData } from "./VideoTile";
|
import { ItemData, TileContent } from "./VideoTile";
|
||||||
|
|
||||||
interface LocalVolumeProps {
|
interface LocalVolumeProps {
|
||||||
participant: RemoteParticipant;
|
participant: RemoteParticipant;
|
||||||
|
content: TileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LocalVolume: React.FC<LocalVolumeProps> = ({
|
const LocalVolume: React.FC<LocalVolumeProps> = ({
|
||||||
participant,
|
participant,
|
||||||
|
content,
|
||||||
}: LocalVolumeProps) => {
|
}: LocalVolumeProps) => {
|
||||||
|
const source =
|
||||||
|
content === TileContent.UserMedia
|
||||||
|
? Track.Source.Microphone
|
||||||
|
: Track.Source.ScreenShareAudio;
|
||||||
|
|
||||||
const [localVolume, setLocalVolume] = useState<number>(
|
const [localVolume, setLocalVolume] = useState<number>(
|
||||||
participant.getVolume() ?? 0
|
participant.getVolume(source) ?? 0
|
||||||
);
|
);
|
||||||
|
|
||||||
const onLocalVolumeChanged = (event: ChangeEvent<HTMLInputElement>) => {
|
const onLocalVolumeChanged = (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
const value: number = +event.target.value;
|
const value: number = +event.target.value;
|
||||||
setLocalVolume(value);
|
setLocalVolume(value);
|
||||||
participant.setVolume(value);
|
participant.setVolume(value, source);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -78,7 +85,10 @@ export const VideoTileSettingsModal = ({ data, onClose, ...rest }: Props) => {
|
|||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<LocalVolume participant={data.sfuParticipant as RemoteParticipant} />
|
<LocalVolume
|
||||||
|
participant={data.sfuParticipant as RemoteParticipant}
|
||||||
|
content={data.content}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user