UNPKG

@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.32 kB
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 useRoomVideoAction() { const { t } = useI18n(); const roomStore = useRoomStore(); const roomEngine = useRoomEngine(); let stateForAllVideo = false; function toggleRoomVideo() { stateForAllVideo = !roomStore.isCameraDisableForAllUser; MessageBox({ title: roomStore.isCameraDisableForAllUser ? t("Enable all videos") : t("All and new members will be banned from the camera"), message: roomStore.isCameraDisableForAllUser ? t("After unlocking, users can freely turn on the camera") : t("Members will not be able to open the camera"), confirmButtonText: t("Confirm"), cancelButtonText: t("Cancel"), callback: async (action) => { if (action === "confirm") { doToggleRoomVideo(); } } }); } async function doToggleRoomVideo() { var _a; if (roomStore.isCameraDisableForAllUser === stateForAllVideo) { const tipMessage = stateForAllVideo ? t("All videos disabled") : t("All videos enabled"); TUIToast({ type: TOAST_TYPE.SUCCESS, message: tipMessage, duration: MESSAGE_DURATION.NORMAL }); return; } await ((_a = roomEngine.instance) == null ? void 0 : _a.disableDeviceForAllUserByAdmin({ isDisable: stateForAllVideo, device: TUIMediaDevice.kCamera })); roomStore.setDisableCameraForAllUserByAdmin(stateForAllVideo); } const roomVideoAction = reactive({ key: RoomAction.VideoAction, icon: defineComponent({}), label: computed( () => roomStore.isCameraDisableForAllUser ? t("Lift stop all video") : t("All stop video") ), handler: toggleRoomVideo }); return roomVideoAction; } export { useRoomVideoAction as default };