mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-27 00:48:06 +08:00
Add ability to adjust sound effect volume.
This commit is contained in:
parent
1df2e0c48f
commit
7b57fc2942
@ -144,6 +144,10 @@
|
|||||||
"room_auth_view_eula_caption": "By clicking \"Continue\", you agree to our <2>End User Licensing Agreement (EULA)</2>",
|
"room_auth_view_eula_caption": "By clicking \"Continue\", you agree to our <2>End User Licensing Agreement (EULA)</2>",
|
||||||
"screenshare_button_label": "Share screen",
|
"screenshare_button_label": "Share screen",
|
||||||
"settings": {
|
"settings": {
|
||||||
|
"audio_tab": {
|
||||||
|
"effect_volume_label": "Sound effect volume",
|
||||||
|
"effect_volume_description": "Adjust the volume at which reactions and hand raised effects play"
|
||||||
|
},
|
||||||
"developer_settings_label": "Developer Settings",
|
"developer_settings_label": "Developer Settings",
|
||||||
"developer_settings_label_description": "Expose developer settings in the settings window.",
|
"developer_settings_label_description": "Expose developer settings in the settings window.",
|
||||||
"developer_tab_title": "Developer",
|
"developer_tab_title": "Developer",
|
||||||
|
@ -8,12 +8,17 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import { ReactNode, useEffect, useRef } from "react";
|
import { ReactNode, useEffect, useRef } from "react";
|
||||||
|
|
||||||
import { useReactions } from "../useReactions";
|
import { useReactions } from "../useReactions";
|
||||||
import { playReactionsSound, useSetting } from "../settings/settings";
|
import {
|
||||||
|
playReactionsSound,
|
||||||
|
effectSoundVolume as effectSoundVolumeSetting,
|
||||||
|
useSetting,
|
||||||
|
} from "../settings/settings";
|
||||||
import { GenericReaction, ReactionSet } from "../reactions";
|
import { GenericReaction, ReactionSet } from "../reactions";
|
||||||
|
|
||||||
export function ReactionsAudioRenderer(): ReactNode {
|
export function ReactionsAudioRenderer(): ReactNode {
|
||||||
const { reactions } = useReactions();
|
const { reactions } = useReactions();
|
||||||
const [shouldPlay] = useSetting(playReactionsSound);
|
const [shouldPlay] = useSetting(playReactionsSound);
|
||||||
|
const [effectSoundVolume] = useSetting(effectSoundVolumeSetting);
|
||||||
const audioElements = useRef<Record<string, HTMLAudioElement | null>>({});
|
const audioElements = useRef<Record<string, HTMLAudioElement | null>>({});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -30,6 +35,7 @@ export function ReactionsAudioRenderer(): ReactNode {
|
|||||||
const audioElement =
|
const audioElement =
|
||||||
audioElements.current[reactionName] ?? audioElements.current.generic;
|
audioElements.current[reactionName] ?? audioElements.current.generic;
|
||||||
if (audioElement?.paused) {
|
if (audioElement?.paused) {
|
||||||
|
audioElement.volume = effectSoundVolume;
|
||||||
void audioElement.play();
|
void audioElement.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,3 +16,20 @@ Please see LICENSE in the repository root for full details.
|
|||||||
.fieldRowText {
|
.fieldRowText {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.volumeSlider {
|
||||||
|
margin-top: var(--cpd-space-2x);
|
||||||
|
}
|
||||||
|
|
||||||
|
.volumeSlider > label {
|
||||||
|
margin-bottom: var(--cpd-space-1x);
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.volumeSlider > span {
|
||||||
|
max-width: 20em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.volumeSlider > p {
|
||||||
|
color: var(--cpd-color-text-secondary);
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import { ChangeEvent, FC, ReactNode, useCallback } from "react";
|
import { ChangeEvent, FC, ReactNode, useCallback } from "react";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||||
import { Dropdown, Text } from "@vector-im/compound-web";
|
import { Dropdown, Separator, Text } from "@vector-im/compound-web";
|
||||||
|
|
||||||
import { Modal } from "../Modal";
|
import { Modal } from "../Modal";
|
||||||
import styles from "./SettingsModal.module.css";
|
import styles from "./SettingsModal.module.css";
|
||||||
@ -28,9 +28,11 @@ import {
|
|||||||
developerSettingsTab as developerSettingsTabSetting,
|
developerSettingsTab as developerSettingsTabSetting,
|
||||||
duplicateTiles as duplicateTilesSetting,
|
duplicateTiles as duplicateTilesSetting,
|
||||||
useOptInAnalytics,
|
useOptInAnalytics,
|
||||||
|
effectSoundVolume,
|
||||||
} from "./settings";
|
} from "./settings";
|
||||||
import { isFirefox } from "../Platform";
|
import { isFirefox } from "../Platform";
|
||||||
import { PreferencesSettingsTab } from "./PreferencesSettingsTab";
|
import { PreferencesSettingsTab } from "./PreferencesSettingsTab";
|
||||||
|
import { Slider } from "../Slider";
|
||||||
|
|
||||||
type SettingsTab =
|
type SettingsTab =
|
||||||
| "audio"
|
| "audio"
|
||||||
@ -116,6 +118,8 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
const devices = useMediaDevices();
|
const devices = useMediaDevices();
|
||||||
useMediaDeviceNames(devices, open);
|
useMediaDeviceNames(devices, open);
|
||||||
|
|
||||||
|
const [soundVolume, setSoundVolume] = useSetting(effectSoundVolume);
|
||||||
|
|
||||||
const audioTab: Tab<SettingsTab> = {
|
const audioTab: Tab<SettingsTab> = {
|
||||||
key: "audio",
|
key: "audio",
|
||||||
name: t("common.audio"),
|
name: t("common.audio"),
|
||||||
@ -127,6 +131,19 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
devices.audioOutput,
|
devices.audioOutput,
|
||||||
t("settings.speaker_device_selection_label"),
|
t("settings.speaker_device_selection_label"),
|
||||||
)}
|
)}
|
||||||
|
<Separator />
|
||||||
|
<div className={styles.volumeSlider}>
|
||||||
|
<label>{t("settings.audio_tab.effect_volume_label")}</label>
|
||||||
|
<p>{t("settings.audio_tab.effect_volume_description")}</p>
|
||||||
|
<Slider
|
||||||
|
label={t("video_tile.volume")}
|
||||||
|
value={soundVolume}
|
||||||
|
onValueChange={setSoundVolume}
|
||||||
|
min={0}
|
||||||
|
max={1}
|
||||||
|
step={0.01}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
@ -100,4 +100,6 @@ export const playReactionsSound = new Setting<boolean>(
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const effectSoundVolume = new Setting<number>("effects-sound-volume", 1);
|
||||||
|
|
||||||
export const alwaysShowSelf = new Setting<boolean>("always-show-self", true);
|
export const alwaysShowSelf = new Setting<boolean>("always-show-self", true);
|
||||||
|
Loading…
Reference in New Issue
Block a user