demo/lib under the main.dart file, add your licenseUrl and licenseKey in this file. The sample code for using beauty features in MLVB is primarily located in demo/lib/page/live_page.dart and demo/lib/main.dart.applicationId to the package name you used when applying for the license.flutter pub get.flutter pub get.pod install.bundle ID (it needs to be the same as the bundle ID you provided when applying for the license).tencent_effect_flutter:git:url: https://github.com/Tencent-RTC/TencentEffect_Flutter
android, ios, lib, and the files pubspec.yaml and tencent_effect_flutter.iml to your project directory. Next, include the following reference in your project's pubspec.yaml file: (Refer to the demo for guidance.)tencent_effect_flutter:path: ../
flutter pub get
flutter pub add tencent_effect_flutter
pubspec.yaml file. By default, the package is set to S1-07. For reference, you can check the specific location in the demo.TencentEffect:te_sub_spec: 'S1-07' // If you're using the S1-04 plan, then just write S1-04 here.
build.gradle file within the app module and add the Maven repository URL corresponding to your selected package. For instance, if you have chosen the S1-04 package, include the following:dependencies {implementation 'com.tencent.mediacloud:TencentEffect_S1-04:latest.release'}
src/main/assets folder within the android/app module of your project. Copy the lut and MotionRes directories from the demo project's demo/android/app/src/main/assets into the corresponding android/app/src/main/assets directory of your own project. If the assets folder does not exist in your project, you may create it manually.<uses-native-libraryandroid:name="libOpenCL.so"android:required="false" />//true means libOpenCL is required for the current app. Without this library, the system won't allow the app to be installed.//false means libOpenCL is not required for the current app. The app can be installed normally whether this library exists or not. If the device has this library, GAN-type effects in the beauty effects SDK will work properly (like Fairy Face, Comic Face). If the device doesn't have this library, GAN effects won't work, but it won't affect other features in the SDK.//For more info about uses-native-library, check out the official Android documentation: https://developer.android.com/guide/topics/manifest/uses-native-library-element

no xxx method.-keep class com.tencent.xmagic.** { *;}-keep class org.light.** { *;}-keep class org.libpag.** { *;}-keep class org.extra.** { *;}-keep class com.gyailib.**{ *;}-keep class com.tencent.cloud.iai.lib.** { *;}-keep class com.tencent.beacon.** { *;}-keep class com.tencent.qimei.** { *;}-keep class androidx.exifinterface.** { *;}-keep class com.tencent.effect.** { *;}
pubspec.yaml file. By default, the package is set to S1-07. For specific placement, you can refer to the demo.TencentEffect:te_sub_spec: 'S1-07' // If you are using the S1-04 plan, then write S1-04 here
ios/tencent_effect_flutter.podspec file within the Beauty Flutter SDK, open it, and modify TencentEffect_All to the desired package. The version number can also be adjusted as needed.pod update command in the ios directory of your project.xmagic folder from the ios/Runner directory in the demo project to the ios/Runner directory in your own project. After adding it, the structure should appear as shown in the following image:
TXLivePluginManager.register(new XmagicProcesserFactory());
XmagicProcesserFactory *instance = [[XmagicProcesserFactory alloc] init];[TXLivePluginManager registerWithCustomBeautyProcesserFactory:instance];

void _initSettings(InitXmagicCallBack callBack) async {String resourceDir = await ResPathManager.getResManager().getResPath();TXLog.printlog('$TAG method is _initResource ,xmagic resource dir is $resourceDir');TencentEffectApi.getApi()?.setResourcePath(resourceDir);/// Resource copying only needs to be done once. In the current version, if copied successfully once, there is no need to copy the resources again./// Copying the resource only needs to be done once. Once it has been successfully copied in the current version, there is no need to copy it again in future versions.if (await isCopiedRes()) {callBack.call(true);return;} else {_copyRes(callBack);}}void _copyRes(InitXmagicCallBack callBack) {_showDialog(context);TencentEffectApi.getApi()?.initXmagic((result) {if (result) {saveResCopied();}_dismissDialog(context);callBack.call(result);if (!result) {Fluttertoast.showToast(msg: "initialization failed");}});}
String dir = await BeautyDataManager.getInstance().getResDir();TXLog.printlog('The file path: $dir');TencentEffectApi.getApi()?.initXmagic(dir,(reslut) {_isInitResource = reslut;callBack.call(reslut);if (!reslut) {Fluttertoast.showToast(msg: "Failed to initialize the resources");}});
TencentEffectApi.getApi()?.setLicense(licenseKey, licenseUrl,(errorCode, msg) {TXLog.printlog("Print the authentication result errorCode = $errorCode msg = $msg");if (errorCode == 0) {// Authentication succeeded}});
/// Enable beauty filter operationvar enableCustomVideo = await _livePusher.enableCustomVideoProcess(open);
TencentEffectApi.getApi()?.setEffect(sdkParam.effectName!,sdkParam.effectValue, sdkParam.resourcePath, sdkParam.extraInfo)
TencentEffectApi.getApi()?.updateProperty(_xmagicProperty!);/// You can call `BeautyDataManager.getInstance().getAllPannelData()` to get all the properties and call `updateProperty` to set properties.
TencentEffectApi.getApi()?.onPause();
TencentEffectApi.getApi()?.onResume();
TencentEffectApi.getApi()?.setOnCreateXmagicApiErrorListener((errorMsg, code) {TXLog.printlog("Error creating an effect object errorMsg = $errorMsg , code = $code");}); /// Needs to be set before creating the beauty filter
TencentEffectApi.getApi()?.setAIDataListener(XmagicAIDataListenerImp());
TencentEffectApi.getApi()?.setTipsListener(XmagicTipsListenerImp());
TencentEffectApi.getApi()?.setYTDataListener((data) {TXLog.printlog("setYTDataListener $data");});
TencentEffectApi.getApi()?.setOnCreateXmagicApiErrorListener(null);TencentEffectApi.getApi()?.setAIDataListener(null);TencentEffectApi.getApi()?.setYTDataListener(null);TencentEffectApi.getApi()?.setTipsListener(null);
void initPanelViewConfig() {String panelDir = "assets/beauty_panel/";String jsonFileSuffix =".json";TEResConfig.getConfig().defaultPanelDataList.clear();// Here’s an example of multilingual adaptation. It checks the current language environment and loads the corresponding language JSON file. By default, the panel’s JSON only supports Simplified Chinese and English. If we want to support Traditional Chinese, here’s how we can do it:// Create a folder named zt_hant under beauty_panel, then copy the existing JSON files into this folder, and change the disPlayName values to Traditional Chinese. When needed, just load this JSON file.// Note: This only adapts the panel JSON files for multiple languages. For text used in the library, you can check demo/lib/languages/TEPanelLocalizationsZhTW.dart.// For multilingual implementation, see: tencent-effect-flutter/docs/MULTI_LANGUAGE_GUIDE_.md// Check if the current device language environment is Traditional ChineseLocale currentLocale = PlatformDispatcher.instance.locale;bool isTraditionalChinese = currentLocale.languageCode == 'zh' &&(currentLocale.countryCode == 'TW' ||currentLocale.countryCode == 'HK' ||currentLocale.countryCode == 'MO' ||currentLocale.scriptCode == 'Hant');if (isTraditionalChinese) {panelDir = "assets/beauty_panel/zh_hant/";jsonFileSuffix = "_zh_hant.json";}TEResConfig.getConfig()..setBeautyTemplateRes("${panelDir}beauty_template${jsonFileSuffix}")..setBeautyRes("${panelDir}beauty${jsonFileSuffix}")..setBeautyRes("${panelDir}beauty_image${jsonFileSuffix}")..setBeautyRes("${panelDir}beauty_makeup${jsonFileSuffix}")..setBeautyRes("${panelDir}beauty_shape${jsonFileSuffix}")..setBeautyBodyRes("${panelDir}beauty_body${jsonFileSuffix}")..setLutRes("${panelDir}lut${jsonFileSuffix}")..setLightMakeupRes("${panelDir}light_makeup${jsonFileSuffix}")..setMakeUpRes("${panelDir}makeup${jsonFileSuffix}")..setMotionRes("${panelDir}motion_2d${jsonFileSuffix}")..setMotionRes("${panelDir}motion_3d${jsonFileSuffix}")..setMotionRes("${panelDir}motion_gesture${jsonFileSuffix}")..setSegmentationRes("${panelDir}segmentation${jsonFileSuffix}");}
TEBeautyPanelViewExpanded(child: TEBeautyPanelView(beautyPanelViewCallBack,null,beautyPanelViewCallBack.panelController,),)

Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback