@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,
64 lines (63 loc) • 2.17 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);
import { isElectron, isWeChat } from "../../utils/environment.mjs";
class VirtualBackground {
constructor(service) {
__publicField(this, "service");
__publicField(this, "virtualBackgroundPluginReady", false);
__publicField(this, "handleUnmount", async () => {
await this.toggleVirtualBackground(false);
await this.toggleTestVirtualBackground(false);
});
this.service = service;
if (isElectron || isWeChat) return;
this.bindEvent();
}
get trtcCloud() {
var _a, _b;
return (_b = (_a = this.service.roomEngine) == null ? void 0 : _a.instance) == null ? void 0 : _b.getTRTCCloud();
}
bindEvent() {
this.service.lifeCycleManager.on("unmount", this.handleUnmount);
}
dispose() {
this.service.lifeCycleManager.off("unmount", this.handleUnmount);
}
async initVirtualBackground() {
var _a;
if (!this.virtualBackgroundPluginReady && ((_a = this.trtcCloud) == null ? void 0 : _a.useVirtualBackground)) {
await this.trtcCloud.useVirtualBackground();
this.virtualBackgroundPluginReady = true;
}
}
async toggleVirtualBackground(enabled) {
await this.initVirtualBackground();
const { sdkAppId, userId, userSig } = this.service.basicStore;
const params = {
sdkAppId,
userId,
userSig,
enable: enabled
};
await this.trtcCloud.callExperimentalAPI(
JSON.stringify({ api: "enableVirtualBackground", params })
);
}
async toggleTestVirtualBackground(enabled) {
await this.initVirtualBackground();
const { sdkAppId, userId, userSig } = this.service.basicStore;
const params = {
sdkAppId,
userId,
userSig,
enable: enabled
};
await this.trtcCloud.callExperimentalAPI(
JSON.stringify({ api: "enableTestVirtualBackground", params })
);
}
}
export {
VirtualBackground
};