@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,
97 lines (96 loc) • 3.07 kB
JavaScript
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const useRoomEngine = require("../../../hooks/useRoomEngine.js");
const room = require("../../../constants/room.js");
const index = require("../../../utils/common/logger/index.js");
const roomEngine = useRoomEngine.default();
let isBeautyReady = false;
const beautyConfig = Vue.ref({
beautyLevel: 0,
whitenessLevel: 0,
ruddinessLevel: 0
});
const cachedBeautyConfig = {
beautyLevel: 0,
whitenessLevel: 0,
ruddinessLevel: 0
};
async function setFreeBeauty(config) {
cachedBeautyConfig.beautyLevel = config.beautyLevel;
cachedBeautyConfig.whitenessLevel = config.whitenessLevel;
cachedBeautyConfig.ruddinessLevel = config.ruddinessLevel;
const beautyLevel = convertLevel(config.beautyLevel);
const whitenessLevel = convertLevel(config.whitenessLevel);
const ruddinessLevel = convertLevel(config.ruddinessLevel);
await startCameraTestBeauty(beautyLevel, whitenessLevel, ruddinessLevel);
}
async function saveBeautySetting() {
var _a;
beautyConfig.value = { ...cachedBeautyConfig };
const trtcCloud = (_a = roomEngine.instance) == null ? void 0 : _a.getTRTCCloud();
if (trtcCloud === void 0) {
index.default.error("trtcCloud is undefined");
return;
}
index.default.log("saveBeautySetting:", beautyConfig.value);
const style = room.TRTCBeautyStyle.TRTCBeautyStyleNature;
const beautyLevel = convertLevel(beautyConfig.value.beautyLevel);
const whitenessLevel = convertLevel(beautyConfig.value.whitenessLevel);
const ruddinessLevel = convertLevel(beautyConfig.value.ruddinessLevel);
await checkInitBeauty();
await trtcCloud.setBeautyStyle(
style,
beautyLevel,
whitenessLevel,
ruddinessLevel
);
}
async function startCameraTestBeauty(beautyLevel, whitenessLevel, ruddinessLevel) {
var _a;
const trtcCloud = (_a = roomEngine.instance) == null ? void 0 : _a.getTRTCCloud();
if (trtcCloud === void 0) {
index.default.error("trtcCloud is undefined");
return;
}
await checkInitBeauty();
await trtcCloud.callExperimentalAPI(
JSON.stringify({
api: "enableTestBeautyStyle",
params: {
style: room.TRTCBeautyStyle.TRTCBeautyStyleNature,
beautyLevel,
whitenessLevel,
ruddinessLevel
}
})
);
}
async function checkInitBeauty() {
var _a;
const trtcCloud = (_a = roomEngine.instance) == null ? void 0 : _a.getTRTCCloud();
if (trtcCloud === void 0) {
index.default.error("trtcCloud is undefined");
return;
}
if (isBeautyReady === false) {
try {
await trtcCloud.useBeautyStyle();
isBeautyReady = true;
} catch (error) {
index.default.error("useBeautyStyle failed, error:", error);
isBeautyReady = false;
}
}
}
function convertLevel(level) {
return Math.floor(level / 100 * 9);
}
function useVideoEffectState() {
return {
beautyConfig,
setFreeBeauty,
saveBeautySetting
};
}
exports.default = useVideoEffectState;
;