@tencentcloud/roomkit-web-vue3
Version:
<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,
59 lines (58 loc) • 2.33 kB
JavaScript
import { TUIMediaDevice } from "@tencentcloud/tuiroom-engine-js";
import { RoomAction } from "../../../type/Room.mjs";
import { useI18n } from "../../../../locales/index.mjs";
import { useRoomStore } from "../../../../stores/room.mjs";
import MessageBox from "../../../../components/common/base/MessageBox/index.mjs";
import { TUIToast, TOAST_TYPE } from "@tencentcloud/uikit-base-component-vue3";
import useRoomEngine from "../../../../hooks/useRoomEngine.mjs";
import { MESSAGE_DURATION } from "../../../../constants/message.mjs";
import { reactive, computed, defineComponent } from "vue";
function useRoomAudioAction() {
const { t } = useI18n();
const roomStore = useRoomStore();
const roomEngine = useRoomEngine();
let stateForAllAudio = false;
function toggleRoomAudio() {
stateForAllAudio = !roomStore.isMicrophoneDisableForAllUser;
MessageBox({
title: roomStore.isMicrophoneDisableForAllUser ? t("Enable all audios") : t("All current and new members will be muted"),
message: roomStore.isMicrophoneDisableForAllUser ? t("After unlocking, users can freely turn on the microphone") : t("Members will not be able to open the microphone"),
confirmButtonText: t("Confirm"),
cancelButtonText: t("Cancel"),
callback: async (action) => {
if (action === "confirm") {
doToggleRoomAudio();
}
}
});
}
async function doToggleRoomAudio() {
var _a;
if (roomStore.isMicrophoneDisableForAllUser === stateForAllAudio) {
const tipMessage = stateForAllAudio ? t("All audios disabled") : t("All audios enabled");
TUIToast({
type: TOAST_TYPE.SUCCESS,
message: tipMessage,
duration: MESSAGE_DURATION.NORMAL
});
return;
}
await ((_a = roomEngine.instance) == null ? void 0 : _a.disableDeviceForAllUserByAdmin({
isDisable: stateForAllAudio,
device: TUIMediaDevice.kMicrophone
}));
roomStore.setDisableMicrophoneForAllUserByAdmin(stateForAllAudio);
}
const roomAudioAction = reactive({
key: RoomAction.AudioAction,
icon: defineComponent({}),
label: computed(
() => roomStore.isMicrophoneDisableForAllUser ? t("Lift all mute") : t("All mute")
),
handler: toggleRoomAudio
});
return roomAudioAction;
}
export {
useRoomAudioAction as default
};