mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Update better-xcloud.user.js
This commit is contained in:
parent
9fec033173
commit
bf135d34d1
54
dist/better-xcloud.user.js
vendored
54
dist/better-xcloud.user.js
vendored
@ -3256,13 +3256,7 @@ function floorToNearest(value, interval) {
|
|||||||
|
|
||||||
// src/modules/shortcuts/shortcut-sound.ts
|
// src/modules/shortcuts/shortcut-sound.ts
|
||||||
class SoundShortcut {
|
class SoundShortcut {
|
||||||
static increaseGainNodeVolume(amount) {
|
static adjustGainNodeVolume(amount) {
|
||||||
SoundShortcut.#adjustGainNodeVolume(amount);
|
|
||||||
}
|
|
||||||
static decreaseGainNodeVolume(amount) {
|
|
||||||
SoundShortcut.#adjustGainNodeVolume(-1 * Math.abs(amount));
|
|
||||||
}
|
|
||||||
static #adjustGainNodeVolume(amount) {
|
|
||||||
if (!getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL)) {
|
if (!getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3290,6 +3284,43 @@ class SoundShortcut {
|
|||||||
static setGainNodeVolume(value) {
|
static setGainNodeVolume(value) {
|
||||||
STATES.currentStream.audioGainNode && (STATES.currentStream.audioGainNode.gain.value = value / 100);
|
STATES.currentStream.audioGainNode && (STATES.currentStream.audioGainNode.gain.value = value / 100);
|
||||||
}
|
}
|
||||||
|
static muteUnmute() {
|
||||||
|
if (getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && STATES.currentStream.audioGainNode) {
|
||||||
|
const gainValue = STATES.currentStream.audioGainNode.gain.value;
|
||||||
|
const settingValue = getPref(PrefKey.AUDIO_VOLUME);
|
||||||
|
let targetValue;
|
||||||
|
if (settingValue === 0) {
|
||||||
|
targetValue = 100;
|
||||||
|
setPref(PrefKey.AUDIO_VOLUME, targetValue);
|
||||||
|
BxEvent.dispatch(window, BxEvent.GAINNODE_VOLUME_CHANGED, {
|
||||||
|
volume: targetValue
|
||||||
|
});
|
||||||
|
} else if (gainValue === 0) {
|
||||||
|
targetValue = settingValue;
|
||||||
|
} else {
|
||||||
|
targetValue = 0;
|
||||||
|
}
|
||||||
|
let status;
|
||||||
|
if (targetValue === 0) {
|
||||||
|
status = t("muted");
|
||||||
|
} else {
|
||||||
|
status = targetValue + "%";
|
||||||
|
}
|
||||||
|
SoundShortcut.setGainNodeVolume(targetValue);
|
||||||
|
Toast.show(`${t("stream")} ❯ ${t("volume")}`, status, { instant: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let $media;
|
||||||
|
$media = document.querySelector("div[data-testid=media-container] audio");
|
||||||
|
if (!$media) {
|
||||||
|
$media = document.querySelector("div[data-testid=media-container] video");
|
||||||
|
}
|
||||||
|
if ($media) {
|
||||||
|
$media.muted = !$media.muted;
|
||||||
|
const status = $media.muted ? t("muted") : t("unmuted");
|
||||||
|
Toast.show(`${t("stream")} ❯ ${t("volume")}`, status, { instant: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/modules/controller-shortcut.ts
|
// src/modules/controller-shortcut.ts
|
||||||
@ -3356,11 +3387,14 @@ class ControllerShortcut {
|
|||||||
case ShortcutAction.STREAM_MENU_TOGGLE:
|
case ShortcutAction.STREAM_MENU_TOGGLE:
|
||||||
StreamUiShortcut.showHideStreamMenu();
|
StreamUiShortcut.showHideStreamMenu();
|
||||||
break;
|
break;
|
||||||
|
case ShortcutAction.STREAM_SOUND_TOGGLE:
|
||||||
|
SoundShortcut.muteUnmute();
|
||||||
|
break;
|
||||||
case ShortcutAction.STREAM_VOLUME_INC:
|
case ShortcutAction.STREAM_VOLUME_INC:
|
||||||
SoundShortcut.increaseGainNodeVolume(10);
|
SoundShortcut.adjustGainNodeVolume(10);
|
||||||
break;
|
break;
|
||||||
case ShortcutAction.STREAM_VOLUME_DEC:
|
case ShortcutAction.STREAM_VOLUME_DEC:
|
||||||
SoundShortcut.decreaseGainNodeVolume(10);
|
SoundShortcut.adjustGainNodeVolume(-10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3456,6 +3490,7 @@ class ControllerShortcut {
|
|||||||
[ShortcutAction.STREAM_STATS_TOGGLE]: [t("stream"), t("stats"), t("show-hide")],
|
[ShortcutAction.STREAM_STATS_TOGGLE]: [t("stream"), t("stats"), t("show-hide")],
|
||||||
[ShortcutAction.STREAM_MICROPHONE_TOGGLE]: [t("stream"), t("microphone"), t("toggle")],
|
[ShortcutAction.STREAM_MICROPHONE_TOGGLE]: [t("stream"), t("microphone"), t("toggle")],
|
||||||
[ShortcutAction.STREAM_MENU_TOGGLE]: [t("stream"), t("menu"), t("show")],
|
[ShortcutAction.STREAM_MENU_TOGGLE]: [t("stream"), t("menu"), t("show")],
|
||||||
|
[ShortcutAction.STREAM_SOUND_TOGGLE]: [t("stream"), t("sound"), t("toggle")],
|
||||||
[ShortcutAction.STREAM_VOLUME_INC]: getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && [t("stream"), t("volume"), t("increase")],
|
[ShortcutAction.STREAM_VOLUME_INC]: getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && [t("stream"), t("volume"), t("increase")],
|
||||||
[ShortcutAction.STREAM_VOLUME_DEC]: getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && [t("stream"), t("volume"), t("decrease")]
|
[ShortcutAction.STREAM_VOLUME_DEC]: getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && [t("stream"), t("volume"), t("decrease")]
|
||||||
}
|
}
|
||||||
@ -4021,6 +4056,7 @@ var BxExposed = {
|
|||||||
source.connect(gainNode).connect(audioCtx.destination);
|
source.connect(gainNode).connect(audioCtx.destination);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
BxLogger.error("setupGainNode", e);
|
BxLogger.error("setupGainNode", e);
|
||||||
|
STATES.currentStream.audioGainNode = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleControllerShortcut: ControllerShortcut.handle,
|
handleControllerShortcut: ControllerShortcut.handle,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user