@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,
127 lines (126 loc) • 5.44 kB
JavaScript
import { defineComponent, inject, computed, onBeforeUnmount, createElementBlock, openBlock, createCommentVNode, unref, createElementVNode, toDisplayString, createVNode, createBlock, withCtx, createTextVNode, Fragment, renderList, normalizeClass } from "vue";
import MicrophoneSelect from "./MicrophoneSelect.vue2.mjs";
import SpeakerSelect from "./SpeakerSelect.vue2.mjs";
import { useI18n } from "../../../locales/index.mjs";
import { TUIButton } from "@tencentcloud/uikit-base-component-vue3";
import { useAudioDeviceState } from "../../hooks/useAudioDeviceState/index.mjs";
import { MediaSettingDisplayMode } from "../../type/MediaDeviceSetting.mjs";
const _hoisted_1 = { class: "audio-setting-tab" };
const _hoisted_2 = {
key: 0,
class: "item-setting"
};
const _hoisted_3 = { class: "title" };
const _hoisted_4 = { class: "flex" };
const _hoisted_5 = {
key: 1,
class: "item-setting"
};
const _hoisted_6 = { class: "title" };
const _hoisted_7 = { class: "mic-bar-container" };
const _hoisted_8 = {
key: 2,
class: "item-setting"
};
const _hoisted_9 = { class: "title" };
const _hoisted_10 = { class: "flex" };
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "AudioSettingTab",
setup(__props) {
const { t } = useI18n();
const {
audioVolume,
isMicrophoneTesting,
isSpeakerTesting,
microphone,
speaker
} = useAudioDeviceState();
const audioSettingProps = inject("audioSettingProps");
const isSimpleMode = computed(
() => (audioSettingProps == null ? void 0 : audioSettingProps.displayMode) === MediaSettingDisplayMode.IconWithPanel
);
const isDetailMode = computed(
() => (audioSettingProps == null ? void 0 : audioSettingProps.displayMode) === MediaSettingDisplayMode.Panel
);
const volumeTotalNum = computed(() => isDetailMode.value ? 36 : 28);
const volumeNum = computed(
() => audioVolume.value * volumeTotalNum.value / 100
);
const showVolume = computed(
() => isSimpleMode.value || isDetailMode.value && isMicrophoneTesting.value
);
function handleMicrophoneTest() {
if (isMicrophoneTesting.value) {
microphone.stopMicDeviceTest();
} else {
microphone.startMicDeviceTest({ interval: 200 });
}
}
async function handleSpeakerTest() {
const SPEAKER_TEST_URL = "https://web.sdk.qcloud.com/trtc/electron/download/resources/media/TestSpeaker.mp3";
if (isSpeakerTesting.value) {
speaker.stopSpeakerDeviceTest();
} else {
speaker.startSpeakerDeviceTest({ filePath: SPEAKER_TEST_URL });
}
}
onBeforeUnmount(() => {
speaker.stopSpeakerDeviceTest();
});
return (_ctx, _cache) => {
var _a, _b, _c, _d;
return openBlock(), createElementBlock("div", _hoisted_1, [
((_a = unref(audioSettingProps)) == null ? void 0 : _a.supportSwitchMicrophone) ? (openBlock(), createElementBlock("div", _hoisted_2, [
createElementVNode("span", _hoisted_3, toDisplayString(unref(t)("Mic")), 1),
createElementVNode("div", _hoisted_4, [
createVNode(MicrophoneSelect, { class: "select" }),
isDetailMode.value ? (openBlock(), createBlock(unref(TUIButton), {
key: 0,
onClick: handleMicrophoneTest
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(isMicrophoneTesting) ? unref(t)("Stop") : unref(t)("Test")), 1)
]),
_: 1
})) : createCommentVNode("", true)
])
])) : createCommentVNode("", true),
((_b = unref(audioSettingProps)) == null ? void 0 : _b.supportAudioLevel) ? (openBlock(), createElementBlock("div", _hoisted_5, [
createElementVNode("span", _hoisted_6, toDisplayString(unref(t)("Output")), 1),
createElementVNode("div", _hoisted_7, [
(openBlock(true), createElementBlock(Fragment, null, renderList(new Array(volumeTotalNum.value).fill(""), (item, index) => {
return openBlock(), createElementBlock("div", {
key: index,
class: normalizeClass([
"mic-bar",
`${showVolume.value && volumeNum.value > index ? "active" : ""}`
])
}, null, 2);
}), 128))
])
])) : createCommentVNode("", true),
((_c = unref(audioSettingProps)) == null ? void 0 : _c.supportSwitchSpeaker) ? (openBlock(), createElementBlock("div", _hoisted_8, [
createElementVNode("span", _hoisted_9, toDisplayString(unref(t)("Speaker")), 1),
createElementVNode("div", _hoisted_10, [
createVNode(SpeakerSelect, {
class: "select",
disabled: ((_d = unref(audioSettingProps)) == null ? void 0 : _d.displayMode) === unref(MediaSettingDisplayMode).Panel
}, null, 8, ["disabled"]),
isDetailMode.value ? (openBlock(), createBlock(unref(TUIButton), {
key: 0,
onClick: handleSpeakerTest
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(isSpeakerTesting) ? unref(t)("Stop") : unref(t)("Test")), 1)
]),
_: 1
})) : createCommentVNode("", true)
])
])) : createCommentVNode("", true)
]);
};
}
});
export {
_sfc_main as default
};