xmagickit
folder in the demo/XiaoShiPin/
directory to the directory of the Podfile in your project.Podfile
and run pod install
.pod 'xmagickit', :path => 'xmagickit/xmagickit.podspec'
Bundle ID
to the bundle ID bound to your license.didFinishLaunchingWithOptions
of AppDelegate
(LicenseURL
and LicenseKey
are the authorization information you obtain from Tencent Cloud). If your SDK version is earlier than 2.5.1, you can find TELicenseCheck.h
in XMagic.framework
; if your SDK version is 2.5.1 or later, TELicenseCheck.h
is in YTCommonXMagic.framework
.[TXUGCBase setLicenceURL:LicenseURL key:LicenseKey];[TELicenseCheck setTELicense:LicenseURL key:LicenseKey completion:^(NSInteger authresult, NSString * _Nonnull errorMsg) {if (authresult == TELicenseCheckOk) {NSLog(@"Authentication successful");} else {NSLog(@"Authentication failed");}}];
Error Code | Description |
0 | Successful. |
-1 | The input parameter is invalid; for example, the URL or KEY is empty. |
-3 | Download failed. Check the network settings. |
-4 | Unable to obtain any Tencent Effect authentication information from the local system, which may be caused by an I/O failure. |
-5 | The VCUBE TEMP license file is empty, which may be caused by an I/O failure. |
-6 | The JSON field in the v_cube.license file is incorrect. Please contact Tencent Cloud team for help. |
-7 | Signature verification failed. Please contact Tencent Cloud team for help. |
-8 | Decryption failed. Please contact Tencent Cloud team for help. |
-9 | The JSON field in TELicense is incorrect. Please contact Tencent Cloud team for help. |
-10 | The Tencent Effect authentication information parsed online is empty. Please contact Tencent Cloud team for help. |
-11 | Failed to write Tencent Effect SDK authentication information to the local file, which may be caused by an I/O failure. |
-12 | Download failed, and failed to parse local assets. |
-13 | Authentication failed. |
Others | Please contact Tencent Cloud team for help. |
CGSize previewSize = [self getPreviewSizeByResolution:self.currentPreviewResolution];NSString *beautyConfigPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];beautyConfigPath = [beautyConfigPath stringByAppendingPathComponent:@"beauty_config.json"];NSFileManager *localFileManager=[[NSFileManager alloc] init];BOOL isDir = YES;NSDictionary * beautyConfigJson = @{};if ([localFileManager fileExistsAtPath:beautyConfigPath isDirectory:&isDir] && !isDir) {NSString *beautyConfigJsonStr = [NSString stringWithContentsOfFile:beautyConfigPath encoding:NSUTF8StringEncoding error:nil];NSError *jsonError;NSData *objectData = [beautyConfigJsonStr dataUsingEncoding:NSUTF8StringEncoding];beautyConfigJson = [NSJSONSerialization JSONObjectWithData:objectDataoptions:NSJSONReadingMutableContainerserror:&jsonError];}NSDictionary *assetsDict = @{@"core_name":@"LightCore.bundle",@"root_path":[[NSBundle mainBundle] bundlePath],@"tnn_"@"beauty_config":beautyConfigJson};// Init beauty kitself.beautyKit = [[XMagic alloc] initWithRenderSize:previewSize assetsDict:assetsDict];
// Register log[self.beautyKit registerSDKEventListener:self];[self.beautyKit registerLoggerListener:self withDefaultLevel:YT_SDK_ERROR_LEVEL];
- (int)configPropertyWithType:(NSString *_Nonnull)propertyType withName:(NSString *_Nonnull)propertyName withData:(NSString*_Nonnull)propertyValue withExtraInfo:(id _Nullable)extraInfo;
YTProcessInput
and pass textureId
to the SDK for rendering.[self.xMagicKit process:inputCPU withOrigin:YtLightImageOriginTopLeft withOrientation:YtLightCameraRotation0]
[self.beautyKit onPause];[self.beautyKit onResume];
UIEdgeInsets gSafeInset;#if __IPHONE_11_0 && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0if(gSafeInset.bottom > 0){}if (@available(iOS 11.0, *)) {gSafeInset = [UIApplication sharedApplication].keyWindow.safeAreaInsets;} else#endif{gSafeInset = UIEdgeInsetsZero;}dispatch_async(dispatch_get_main_queue(), ^{// Effect option UI_vBeauty = [[BeautyView alloc] init];[self.view addSubview:_vBeauty];[_vBeauty mas_makeConstraints:^(MASConstraintMaker *make) {make.width.mas_equalTo(self.view);make.centerX.mas_equalTo(self.view);make.height.mas_equalTo(254);if(gSafeInset.bottom > 0.0){ // Adapt to full-view screenmake.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(0);} else {make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(-10);}}];_vBeauty.hidden = YES;});
Was this page helpful?