@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,
148 lines (147 loc) • 5.87 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const TUIRoomEngine = require("@tencentcloud/tuiroom-engine-js");
const useRoomEngine = require("../../../hooks/useRoomEngine.js");
const useDeviceManager = require("../../../hooks/useDeviceManager.js");
const index$1 = require("../../../locales/index.js");
const index = require("../../../components/common/base/MessageBox/index.js");
const uikitBaseComponentVue3 = require("@tencentcloud/uikit-base-component-vue3");
const environment = require("../../../utils/environment.js");
const MediaDeviceSetting = require("../../type/MediaDeviceSetting.js");
const message = require("../../../constants/message.js");
require("../../../services/main.js");
const roomService = require("../../../services/roomService.js");
require("mitt");
require("../../../services/manager/roomActionManager.js");
require("@tencentcloud/tui-core");
const videoDeviceManagerState = require("./videoDeviceManagerState.js");
const videoDeviceListHandler = require("./videoDeviceListHandler.js");
const { t } = index$1.default.global;
const roomEngine = useRoomEngine.default();
const deviceManager = useDeviceManager.default();
const {
currentCameraDevice,
isFrontCamera,
cameraState,
isCameraTesting,
isCameraTestLoading,
localVideoQuality,
isLocalMirror
} = videoDeviceManagerState.default();
const _Camera = class _Camera {
constructor() {
if (!_Camera.instance) {
_Camera.instance = this;
}
return _Camera.instance;
}
async startCameraDeviceTest(options) {
var _a;
if (!videoDeviceManagerState.isCameraListInitiated) {
await videoDeviceListHandler.initMediaDeviceList();
}
isCameraTestLoading.value = true;
try {
await ((_a = deviceManager.instance) == null ? void 0 : _a.startCameraDeviceTest(options));
isCameraTestLoading.value = false;
isCameraTesting.value = true;
} catch (error) {
isCameraTestLoading.value = false;
}
}
async stopCameraDeviceTest() {
var _a;
isCameraTestLoading.value = false;
await ((_a = deviceManager.instance) == null ? void 0 : _a.stopCameraDeviceTest());
isCameraTesting.value = false;
}
async switchCamera(options) {
var _a;
await ((_a = deviceManager.instance) == null ? void 0 : _a.switchCamera(options));
isFrontCamera.value = options.isFrontCamera;
}
async switchMirror(options) {
var _a;
const trtcCloud = (_a = roomEngine.instance) == null ? void 0 : _a.getTRTCCloud();
await (trtcCloud == null ? void 0 : trtcCloud.setLocalRenderParams({
mirrorType: options.mirror ? TUIRoomEngine.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable : TUIRoomEngine.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable,
rotation: TUIRoomEngine.TRTCVideoRotation.TRTCVideoRotation0,
fillMode: TUIRoomEngine.TRTCVideoFillMode.TRTCVideoFillMode_Fill
}));
if (isLocalMirror.value !== options.mirror) {
isLocalMirror.value = options.mirror;
}
}
async updateVideoQuality(options) {
var _a;
await ((_a = roomEngine.instance) == null ? void 0 : _a.updateVideoQuality(options));
localVideoQuality.value = options.quality;
}
async openLocalCamera() {
var _a, _b;
if (cameraState.value === MediaDeviceSetting.MediaDeviceState.NotSupportCapture && !environment.isWeChat) {
index.default({
title: t("Note"),
message: t("The current browser does not support capturing video"),
confirmButtonText: t("Sure")
});
return;
}
if (cameraState.value === MediaDeviceSetting.MediaDeviceState.NoDeviceDetected && !environment.isWeChat) {
index.default({
title: t("Note"),
message: t("Camera not detected on current device"),
confirmButtonText: t("Sure")
});
return;
}
if (cameraState.value === MediaDeviceSetting.MediaDeviceState.DeviceOffAndDisabled) {
let warningMessage = "";
if (roomService.roomService.roomStore.isAudience) {
warningMessage = message.WARNING_MESSAGE.UNMUTE_LOCAL_CAMERA_FAIL_AUDIENCE;
} else if (roomService.roomService.roomStore.isCameraDisableForAllUser) {
warningMessage = message.WARNING_MESSAGE.UNMUTE_LOCAL_CAMERA_FAIL_MUTE_ALL;
}
uikitBaseComponentVue3.TUIToast({
type: uikitBaseComponentVue3.TOAST_TYPE.WARNING,
message: t(warningMessage),
duration: message.MESSAGE_DURATION.NORMAL
});
return;
}
if (environment.isMobile) {
await ((_a = roomEngine.instance) == null ? void 0 : _a.openLocalCamera({
isFrontCamera: isFrontCamera.value
}));
} else {
await ((_b = roomEngine.instance) == null ? void 0 : _b.openLocalCamera());
}
}
async closeLocalCamera() {
var _a;
await ((_a = roomEngine.instance) == null ? void 0 : _a.closeLocalCamera());
}
async setCurrentDevice(options) {
var _a, _b;
const { deviceId } = options;
await ((_a = deviceManager.instance) == null ? void 0 : _a.setCurrentDevice({
type: TUIRoomEngine.TUIMediaDeviceType.kMediaDeviceTypeVideoCamera,
deviceId
}));
currentCameraDevice.value = (_b = deviceManager.instance) == null ? void 0 : _b.getCurrentDevice({
type: TUIRoomEngine.TUIMediaDeviceType.kMediaDeviceTypeVideoCamera
});
}
};
__publicField(_Camera, "instance");
let Camera = _Camera;
const camera = new Camera();
function useVideoDeviceManager() {
return {
camera
};
}
exports.default = useVideoDeviceManager;
;