@tencentcloud/roomkit-electron-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,
119 lines (118 loc) • 4.29 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const TUIRoomEngine = require("@tencentcloud/tuiroom-engine-electron");
const room = require("../../../../stores/room.js");
const roomService = require("../../../../services/roomService.js");
const mediaManager = require("../../../../services/manager/mediaManager.js");
const basic = require("../../../../stores/basic.js");
const pinia = require("pinia");
const utils = require("../../../../utils/utils.js");
const _hoisted_1 = ["id"];
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
__name: "index",
props: {
streamInfo: {},
streamPlayQuality: { default: mediaManager.StreamPlayQuality.Default },
streamPlayMode: { default: mediaManager.StreamPlayMode.PLAY }
},
setup(__props) {
const mediaManager$1 = roomService.roomService.getMediaManager();
const basicStore = basic.useBasicStore();
const roomStore = room.useRoomStore();
const { defaultStreamType, streamInfoObj } = pinia.storeToRefs(roomStore);
const props = __props;
const playRegionDomRef = Vue.ref();
const nanoId = utils.getNanoId(5);
const playRegionDomId = Vue.computed(
() => `${props.streamInfo.userId}_${props.streamInfo.streamType}_${nanoId}`
);
const isNeedPlayStream = Vue.computed(
() => props.streamPlayMode !== mediaManager.StreamPlayMode.STOP && props.streamInfo.hasVideoStream
);
const streamTypeToFetch = Vue.computed(() => {
const { streamType, userId } = props.streamInfo;
const { userId: localUserId } = basicStore;
if (streamType === TUIRoomEngine.TUIVideoStreamType.kScreenStream) {
return TUIRoomEngine.TUIVideoStreamType.kScreenStream;
}
if (props.streamPlayQuality === mediaManager.StreamPlayQuality.HIGH || userId === localUserId) {
return TUIRoomEngine.TUIVideoStreamType.kCameraStream;
}
if (props.streamPlayQuality === mediaManager.StreamPlayQuality.LOW) {
return TUIRoomEngine.TUIVideoStreamType.kCameraStreamLow;
}
return defaultStreamType.value;
});
async function startPlayVideo() {
if (!streamInfoObj.value[`${props.streamInfo.userId}_${props.streamInfo.streamType}`] || !playRegionDomRef.value) {
return;
}
await Vue.nextTick();
if (isNeedPlayStream.value) {
await mediaManager$1.startPlayVideo({
userId: props.streamInfo.userId,
streamType: streamTypeToFetch.value,
view: playRegionDomRef.value,
observerViewInVisible: props.streamPlayMode === mediaManager.StreamPlayMode.PLAY_IN_VISIBLE
});
}
}
async function stopPlayVideo() {
await mediaManager$1.stopPlayVideo({
userId: props.streamInfo.userId,
streamType: streamTypeToFetch.value,
view: playRegionDomRef.value
});
}
Vue.watch(
() => [
props.streamInfo.userId,
props.streamInfo.streamType,
isNeedPlayStream.value
],
async (val, oldVal) => {
const [oldUserId, oldStreamType] = oldVal;
if (oldUserId !== props.streamInfo.userId || oldStreamType !== props.streamInfo.streamType) {
mediaManager$1.stopPlayVideo({
userId: oldUserId,
streamType: oldStreamType,
view: playRegionDomRef.value
});
}
if (isNeedPlayStream.value) {
await startPlayVideo();
} else {
await stopPlayVideo();
}
}
);
Vue.watch(
() => streamTypeToFetch,
async () => {
if (isNeedPlayStream.value) {
await startPlayVideo();
}
}
);
Vue.onMounted(async () => {
if (isNeedPlayStream.value) {
await startPlayVideo();
}
});
Vue.onBeforeUnmount(async () => {
if (isNeedPlayStream.value) {
await stopPlayVideo();
}
});
return (_ctx, _cache) => {
return Vue.openBlock(), Vue.createElementBlock("div", {
ref_key: "playRegionDomRef",
ref: playRegionDomRef,
id: playRegionDomId.value,
class: "stream-play-container"
}, null, 8, _hoisted_1);
};
}
});
exports.default = _sfc_main;