Move MicrophoneState to shortcut-microphone

This commit is contained in:
redphx 2024-05-25 07:51:51 +07:00
parent 774a822e69
commit 90df5d655f
2 changed files with 11 additions and 9 deletions

View File

@ -3,15 +3,8 @@ import { BxIcon } from "@utils/bx-icon";
import { createButton, ButtonStyle, CE } from "@utils/html"; import { createButton, ButtonStyle, CE } from "@utils/html";
import { t } from "@utils/translation"; import { t } from "@utils/translation";
import { BaseGameBarAction } from "./action-base"; import { BaseGameBarAction } from "./action-base";
import { MicrophoneShortcut } from "../shortcuts/shortcut-microphone"; import { MicrophoneShortcut, MicrophoneState } from "../shortcuts/shortcut-microphone";
enum MicrophoneState {
REQUESTED = 'Requested',
ENABLED = 'Enabled',
MUTED = 'Muted',
NOT_ALLOWED = 'NotAllowed',
NOT_FOUND = 'NotFound',
}
export class MicrophoneAction extends BaseGameBarAction { export class MicrophoneAction extends BaseGameBarAction {
$content: HTMLElement; $content: HTMLElement;

View File

@ -1,6 +1,15 @@
import { t } from "@utils/translation"; import { t } from "@utils/translation";
import { Toast } from "@utils/toast"; import { Toast } from "@utils/toast";
export enum MicrophoneState {
REQUESTED = 'Requested',
ENABLED = 'Enabled',
MUTED = 'Muted',
NOT_ALLOWED = 'NotAllowed',
NOT_FOUND = 'NotFound',
}
export class MicrophoneShortcut { export class MicrophoneShortcut {
static toggle(showToast: boolean = true): boolean { static toggle(showToast: boolean = true): boolean {
if (!window.BX_EXPOSED.streamSession) { if (!window.BX_EXPOSED.streamSession) {
@ -8,7 +17,7 @@ export class MicrophoneShortcut {
} }
const state = window.BX_EXPOSED.streamSession._microphoneState; const state = window.BX_EXPOSED.streamSession._microphoneState;
const enableMic = state === 'Enabled' ? false : true; const enableMic = state === MicrophoneState.ENABLED ? false : true;
try { try {
window.BX_EXPOSED.streamSession.tryEnableChatAsync(enableMic); window.BX_EXPOSED.streamSession.tryEnableChatAsync(enableMic);