@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,
63 lines (62 loc) • 2.24 kB
JavaScript
import { defineComponent, ref, watch, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList } from "vue";
import Select from "../../../components/common/base/Select/index.mjs";
import OPtion from "../../../components/common/base/Option/index.mjs";
import { useAudioDeviceState } from "../../hooks/useAudioDeviceState/index.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "MicrophoneSelect",
props: {
onChange: {},
disabled: { type: Boolean, default: false }
},
setup(__props) {
const { microphoneList, currentMicrophoneId, microphone } = useAudioDeviceState();
const props = __props;
const currentDeviceId = ref(currentMicrophoneId.value);
watch(
currentMicrophoneId,
(val) => {
if (currentDeviceId.value !== val) {
currentDeviceId.value = val;
}
},
{ immediate: true }
);
async function handleChange(deviceId) {
var _a;
(_a = props.onChange) == null ? void 0 : _a.call(props, deviceId);
try {
await microphone.setCurrentDevice({ deviceId });
} catch (error) {
if (microphoneList.value.map((item) => item.deviceId).includes(currentMicrophoneId.value)) {
currentDeviceId.value = currentMicrophoneId.value;
}
}
}
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(Select), {
modelValue: currentDeviceId.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentDeviceId.value = $event),
placeholder: "placeholder",
class: "select",
disabled: _ctx.disabled,
teleported: false,
"popper-append-to-body": false,
onChange: handleChange
}, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(microphoneList), (item) => {
return openBlock(), createBlock(unref(OPtion), {
key: item.deviceId,
label: item.deviceName,
value: item.deviceId
}, null, 8, ["label", "value"]);
}), 128))
]),
_: 1
}, 8, ["modelValue", "disabled"]);
};
}
});
export {
_sfc_main as default
};