Add shortcuts to control stream's volume

This commit is contained in:
redphx
2024-05-25 09:50:41 +07:00
parent 90df5d655f
commit dcbae39042
8 changed files with 96 additions and 7 deletions

View File

@@ -36,6 +36,7 @@ export enum BxEvent {
MICROPHONE_STATE_CHANGED = 'bx-microphone-state-changed',
CAPTURE_SCREENSHOT = 'bx-capture-screenshot',
GAINNODE_VOLUME_CHANGED = 'bx-gainnode-volume-changed',
}
export enum XcloudEvent {

View File

@@ -753,11 +753,13 @@ export class Preferences {
return this.#prefs[key];
}
set(key: PrefKey, value: any) {
set(key: PrefKey, value: any): any {
value = this.#validateValue(key, value);
this.#prefs[key] = value;
this.#updateStorage();
return value;
}
#updateStorage() {

View File

@@ -183,7 +183,7 @@ export class SettingElement {
$range.addEventListener('input', e => {
value = parseInt((e.target as HTMLInputElement).value);
$text.textContent = renderTextValue(value);
onChange && onChange(e, value);
!(e as any).ignoreOnChange && onChange && onChange(e, value);
});
$wrapper.appendChild($range);

View File

@@ -15,7 +15,7 @@ export class Toast {
static #timeout?: number | null;
static #DURATION = 3000;
static show(msg: string, status?: string, options: Partial<ToastOptions>={}) {
static show(msg: string, status?: string, options: Partial<ToastOptions> = {}) {
options = options || {};
const args = Array.from(arguments) as [string, string, ToastOptions];
@@ -43,7 +43,7 @@ export class Toast {
// Get values from item
const [msg, status, options] = Toast.#stack.shift()!;
if (options.html) {
if (options && options.html) {
Toast.#$msg.innerHTML = msg;
} else {
Toast.#$msg.textContent = msg;

View File

@@ -77,3 +77,16 @@ export function renderString(str: string, obj: any){
return match;
});
}
export function ceilToNearest(value: number, interval: number): number {
return Math.ceil(value / interval) * interval;
}
export function floorToNearest(value: number, interval: number): number {
return Math.floor(value / interval) * interval;
}
export function roundToNearest(value: number, interval: number): number {
return Math.round(value / interval) * interval;
}