Android
How to Run the Demo
1. Download the Demo and unzip it.
2. Use Android Studio to open the project
LiteAVDemo(UGC).3. In the
xiaoshipindemo module, find the LicenseManager class and fill in the applied short video License and Tencent Effect License information:ugcLicenceUrl / ugcKey: the authorization URL and key of the short video License;xmagicAuthLicenceUrl / xmagicAuthKey: the authorization URL and key of the Tencent Effect License.4. In the
app module, find the build.gradle file and change the value of applicationId to the Android package name filled in when applying for the License.SDK Integration
1. Integration TencentEffect
2. Integration TEBeautyKit
Add panel JSON file(optional if not using default panel)
SDK Usage
Step 1: Set up the panel JSON file
Add the corresponding JSON file for the beauty panel. For detailed instructions, please refer to the Integration and Usage of TEBeautyKit.
Step 2: Set the resource storage path and copy resources
//The following is a code snippet from TEBeautySDKManger.javaTEBeautyKit.setResPath(new File(applicationContext.getFilesDir(), "ugc_xmagic").getAbsolutePath());TEBeautyKit.copyRes(applicationContext); //This method is time-consuming and needs to be executed in a child thread
Step 3: Authentication
Authentication must be completed before creating the beauty object.
//The following is a code snippet from TEBeautySDKManger.javaTEBeautyKit.setTELicense(applicationContext, xmagicAuthLicenceUrl, xmagicAuthKey, listener);
Step 4: Create the beauty object and set it into the panel
private void initTEBeautyKit() {mBeautyKit = new TEBeautyKit(getContext().getApplicationContext(), XmagicConstant.EffectMode.PRO);mCustomPropertyManager.setBeautyKit(mBeautyKit);mPanelView.setupWithTEBeautyKit(mBeautyKit); //Set the beauty object into the panel, so that beauty properties can be adjusted when operating the panel}
Step 5: Add beauty processing on the recording page
private void registerVideoProcessListener() {TXUGCRecord instance = TXUGCRecord.getInstance(UGCKit.getAppContext());instance.setVideoProcessListener(new TXUGCRecord.VideoCustomProcessListener() {@Overridepublic int onTextureCustomProcess(int textureId, int width, int height) {if (mBeautyType == 1 && mBeautyKit != null) {return mBeautyKit.process(textureId, width, height);}return textureId;}@Overridepublic void onDetectFacePoints(float[] floats) {}@Overridepublic void onTextureDestroyed() {if (Looper.getMainLooper() != Looper.myLooper()) { //non-main threadmCustomPropertyManager.setBeautyKit(null);if (mBeautyKit != null) {mLastParamList = mBeautyKit.exportInUseSDKParam();mBeautyKit.onDestroy();}mIsTextureDestroyed = true;unRegisterVideoProcessListener();}}});}
Step 6: Destroy the beauty object
In the onTextureDestroyed method in Step 5, destroy the beauty object.
public void onTextureDestroyed() {if (Looper.getMainLooper() != Looper.myLooper()) { //non-main threadmCustomPropertyManager.setBeautyKit(null);if (mBeautyKit != null) {mLastParamList = mBeautyKit.exportInUseSDKParam(); //Export beauty parametersmBeautyKit.onDestroy(); //Destroy the beauty object}mIsTextureDestroyed = true;unRegisterVideoProcessListener();}}
Step 7: Resume sound
/*** Used to resume the sound in stickers* Resume the gyroscope sensor, generally called in the Activity's onResume method*/this.mBeautyKit.onResume()
Step 8: Pause sound
/*** Used to pause the sound in stickers* Pause the gyroscope sensor, generally called in the Activity's onPause method*/this.mBeautyKit.onPause()
For detailed calls, please refer to the UGCKitVideoRecord class in the Demo project.
