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,

88 lines (87 loc) 3.68 kB
import { defineComponent, inject, ref, computed, withDirectives, createElementBlock, openBlock, createVNode, unref, withCtx, vShow } from "vue"; import IconButton from "../../../components/common/base/IconButton.vue.mjs"; import AudioIcon from "../../../components/common/AudioIcon.vue2.mjs"; import AudioSettingTab from "./AudioSettingTab.vue2.mjs"; import { useI18n } from "../../../locales/index.mjs"; import vClickOutside from "../../../directives/vClickOutside.mjs"; import { useAudioDeviceState } from "../../hooks/useAudioDeviceState/index.mjs"; import { MediaDeviceState, MediaSettingDisplayMode } from "../../type/MediaDeviceSetting.mjs"; import { useBasicStore } from "../../../stores/basic.mjs"; const _hoisted_1 = { class: "audio-control-container" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "AudioMediaControl", emits: ["click-icon"], setup(__props, { emit: __emit }) { const audioSettingProps = inject("audioSettingProps"); const basicStore = useBasicStore(); const { audioVolume, microphoneState, isMicrophoneTesting, microphone } = useAudioDeviceState(); const emits = __emit; const showAudioSettingTab = ref(false); const { t } = useI18n(); const isMuted = computed(() => { if (!basicStore.roomId) { return !isMicrophoneTesting.value; } return microphoneState.value !== MediaDeviceState.DeviceOn; }); async function handleClickIcon() { showAudioSettingTab.value = false; emits("click-icon"); if (!basicStore.roomId) { if (isMicrophoneTesting.value) { await microphone.stopMicDeviceTest(); } else { await microphone.startMicDeviceTest({ interval: 200 }); } return; } if (microphoneState.value === MediaDeviceState.DeviceOn) { await microphone.muteLocalAudio(); } else { await microphone.openLocalMicrophone(); await microphone.unmuteLocalAudio(); } } function handleMore() { showAudioSettingTab.value = !showAudioSettingTab.value; } function handleHideAudioSettingTab() { if (showAudioSettingTab.value) { showAudioSettingTab.value = false; } } return (_ctx, _cache) => { var _a; return withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(IconButton, { title: unref(t)("Mic"), "has-more": ((_a = unref(audioSettingProps)) == null ? void 0 : _a.displayMode) === unref(MediaSettingDisplayMode).IconWithPanel, disabled: unref(microphoneState) === unref(MediaDeviceState).DeviceOffAndDisabled, "is-not-support": unref(microphoneState) === unref(MediaDeviceState).NotSupportCapture || unref(microphoneState) === unref(MediaDeviceState).NoDeviceDetected, onClickIcon: handleClickIcon, onClickMore: handleMore }, { default: withCtx(() => [ createVNode(AudioIcon, { "audio-volume": unref(audioVolume), "is-muted": isMuted.value, "is-disabled": unref(microphoneState) === unref(MediaDeviceState).DeviceOffAndDisabled }, null, 8, ["audio-volume", "is-muted", "is-disabled"]) ]), _: 1 }, 8, ["title", "has-more", "disabled", "is-not-support"]), withDirectives(createVNode(AudioSettingTab, { class: "audio-tab", "audio-volume": unref(audioVolume) }, null, 8, ["audio-volume"]), [ [vShow, showAudioSettingTab.value] ]) ])), [ [unref(vClickOutside), handleHideAudioSettingTab] ]); }; } }); export { _sfc_main as default };