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,
86 lines (85 loc) • 3.67 kB
JavaScript
import { defineComponent, inject, ref, computed, withDirectives, openBlock, createElementBlock, createVNode, unref, withCtx, vShow } from "vue";
import IconButton from "../../../components/common/base/IconButton.vue.mjs";
import SvgIcon from "../../../components/common/base/SvgIcon.vue.mjs";
import CameraOnIcon from "../../../components/common/icons/CameraOnIcon.vue.mjs";
import CameraOffIcon from "../../../components/common/icons/CameraOffIcon.vue.mjs";
import VideoSettingTab from "./VideoSettingTab.vue2.mjs";
import { useI18n } from "../../../locales/index.mjs";
import vClickOutside from "../../../directives/vClickOutside.mjs";
import { useVideoDeviceState } from "../../hooks/useVideoDeviceState/index.mjs";
import { MediaDeviceState, MediaSettingDisplayMode } from "../../type/MediaDeviceSetting.mjs";
import { storeToRefs } from "pinia";
import { useRoomStore } from "../../../stores/room.mjs";
import { useBasicStore } from "../../../stores/basic.mjs";
const _hoisted_1 = { class: "video-control-container" };
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "VideoMediaControl",
emits: ["click-icon"],
setup(__props, { emit: __emit }) {
const videoSettingProps = inject("videoSettingProps");
const emits = __emit;
const { cameraState, isCameraTesting, camera } = useVideoDeviceState();
const basicStore = useBasicStore();
const roomStore = useRoomStore();
const { localUser } = storeToRefs(roomStore);
const { t } = useI18n();
const showVideoSettingTab = ref(false);
const icon = computed(() => {
if (!basicStore.roomId) {
return isCameraTesting.value ? CameraOnIcon : CameraOffIcon;
}
return cameraState.value === MediaDeviceState.DeviceOn ? CameraOnIcon : CameraOffIcon;
});
async function handleClickIcon() {
showVideoSettingTab.value = false;
emits("click-icon");
if (!basicStore.roomId) {
if (isCameraTesting.value) {
await camera.stopCameraDeviceTest();
} else {
await camera.startCameraDeviceTest({ view: "video-preview" });
}
return;
}
if (localUser.value.hasVideoStream) {
await camera.closeLocalCamera();
} else {
await camera.openLocalCamera();
}
}
function handleMore() {
showVideoSettingTab.value = !showVideoSettingTab.value;
}
function handleHideVideoSettingTab() {
if (showVideoSettingTab.value) {
showVideoSettingTab.value = false;
}
}
return (_ctx, _cache) => {
var _a;
return withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
createVNode(IconButton, {
title: unref(t)("Camera"),
"has-more": ((_a = unref(videoSettingProps)) == null ? void 0 : _a.displayMode) === unref(MediaSettingDisplayMode).IconWithPanel,
disabled: unref(cameraState) === unref(MediaDeviceState).DeviceOffAndDisabled,
"is-not-support": unref(cameraState) === unref(MediaDeviceState).NotSupportCapture || unref(cameraState) === unref(MediaDeviceState).NoDeviceDetected,
onClickIcon: handleClickIcon,
onClickMore: handleMore
}, {
default: withCtx(() => [
createVNode(SvgIcon, { icon: icon.value }, null, 8, ["icon"])
]),
_: 1
}, 8, ["title", "has-more", "disabled", "is-not-support"]),
withDirectives(createVNode(VideoSettingTab, { class: "video-tab" }, null, 512), [
[vShow, showVideoSettingTab.value]
])
])), [
[unref(vClickOutside), handleHideVideoSettingTab]
]);
};
}
});
export {
_sfc_main as default
};