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,

63 lines (62 loc) 2.21 kB
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: "SpeakerSelect", props: { onChange: {}, disabled: { type: Boolean, default: false } }, setup(__props) { const props = __props; const { speakerList, currentSpeakerId, speaker } = useAudioDeviceState(); const currentDeviceId = ref(currentSpeakerId.value); watch( currentSpeakerId, (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 speaker.setCurrentDevice({ deviceId }); } catch (error) { if (speakerList.value.map((item) => item.deviceId).includes(currentSpeakerId.value)) { currentDeviceId.value = currentSpeakerId.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(speakerList), (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 };