The SDK is supported on iOS 8.0 or later.
Decompress the downloaded SDK resource package and copy the framework files whose filename starts with TXLiteAVSDK\_
(such as TXLiteAVSDK_UGC.framework
) in the SDK folder to the project folder and drag them to the project.
bitcode
in Build Settings and set Enable Bitcode to NO.The app needs access to the photo album, which can be configured in Info.plist
. Right-click Info.plist
, select Open as > Source Code, and copy and modify the code below.
<key>NSAppleMusicUsageDescription</key>
<string>Video Cloud Toolkit needs to access your media library to obtain music files. It cannot add music if you deny it access.</string>
<key>NSCameraUsageDescription</key>
<string>Video Cloud Toolkit needs to access your camera to be able to shoot video.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Video Cloud Toolkit needs to access your mic to be able to shoot videos with audio.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Video Cloud Toolkit needs to access your photo album to save edited video files.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Video Cloud Toolkit needs to access your photo album to edit your video files.</string>
Follow the steps in License Application to apply for a license, and copy the key and license URL in the console.
2. Before you integrate UGSV features into your application, we recommend you set - [AppDelegate application:didFinishLaunchingWithOptions:]
as follows:
@import TXLiteAVSDK_UGC;
@implementation AppDelegate
- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictinoary*)options {
NSString * const licenceURL = @"<License URL obtained>";
NSString * const licenceKey = @"<The key obtained>";
[TXUGCBase setLicenceURL:licenceURL key:licenceKey];
NSLog(@"SDK Version = %@", [TXLiveBase getSDKVersionStr]);
}
@end
Note:If you use a license for the SDK on v4.7 and have upgraded the SDK to v4.9, you can click Switch to New License in the console to generate a new license key and URL. A new license can be used only for the SDK on v4.9 or later and should be configured as described above.
You can enable/disable console log printing and set the log level in TXLiveBase
. Below are the APIs used.
[TXLiveBase setConsoleEnabled:YES];
[TXLiveBase setLogLevel:LOGLEVEL_DEBUG];
If the above steps are performed correctly, you will be able to successfully compile the HelloSDK
project. Run the app in the debug mode, and the following SDK version information will be printed in the Xcode console:
2017-09-26 16:16:15.767 HelloSDK[17929:7488566] SDK Version = 5.2.5541
UGCKit is a UI component library built based on the UGSV SDK. It helps you quickly integrate different features of the SDK.
You can find UGCKit in Demo/TXLiteAVDemo/UGC/UGCKit
of the SDK package, which you can download at GitHub or here.
pod init && pod install
to get the Podfile.Open the Podfile and add the following:
pod 'UGCKit', :path => 'UGCKit/UGCKit.podspec', :subspecs => ["UGC"] #subspecs Choose according to your SDK
To integrate basic beauty filters, copy the BeautySettingKit folder to the project root directory (the directory of the Podfile) and add the following to the Podfile:
pod 'BeautySettingKit', :path => 'BeautySettingKit/BeautySettingKit.podspec'
To integrate the Tencent Effect SDK, copy the xmagickit folder to the project root directory (the directory of the Podfile) and add the following to the Podfile:
pod 'xmagickit', :path => 'xmagickit/xmagickit.podspec'
Run pod install and open project name.xcworkspace
. You will find UGCKit
, BeautySettingKit
, and magickit
in the Pods/Development Pods
directory.
UGCKitRecordViewController
provides the video shooting feature. To enable the feature, just instantiate the controller and display it in the UI.UGCKitRecordViewController *recordViewController = [[UGCKitRecordViewController alloc] initWithConfig:nil theme:nil];
[self.navigationController pushViewController:recordViewController]
Shooting results are called back via the completion block, as shown below:
recordViewController.completion = ^(UGCKitResult *result) {
if (result.error) {
// Shooting error.
[self showAlertWithError:error];
} else {
if (result.cancelled) {
// User cancelled shooting and left the shooting view.
[self.navigationController popViewControllerAnimated:YES];
} else {
// Shooting successful. Use the result for subsequent processing.
[self processRecordedVideo:result.media];
}
}
};
UGCKitEditViewController
provides the slideshow making and video editing features. During instantiation, you need to pass in the media object to be edited. Below is an example that involves the editing of a shooting result:- (void)processRecordedVideo:(UGCKitMedia *)media {
// Instantiate the editing view controller.
UGCKitEditViewController *editViewController = [[UKEditViewController alloc] initWithMedia:media conifg:nil theme:nil];
// Display the editing view controller.
[self.navigationController pushViewController:editViewController animated:YES];
Editing results are called back via the completion block, as shown below:
editViewController.completion = ^(UGCKitResult *result) {
if (result.error) {
// Error.
[self showAlertWithError:error];
} else {
if (result.cancelled) {
// User cancelled shooting and left the editing view.
[self.navigationController popViewControllerAnimated:YES];
} else {
// Video edited and saved successfully. Use the result for subsequent processing.
[self processEditedVideo:result.path];
}
}
}
Selecting video or image from photo album
UGCKitMediaPickerViewController
is used to select and splice media files. If multiple video files are selected, a spliced video file will be returned as follows:
// Configure initialization.
UGCKitMediaPickerConfig *config = [[UGCKitMediaPickerConfig alloc] init];
config.mediaType = UGCKitMediaTypeVideo;//Select videos.
config.maxItemCount = 5; // Up to five can be selected.
// Instantiate the media picker view controller.
UGCKitMediaPickerViewController *mediaPickerViewController = [[UGCKitMediaPickerViewController alloc] initWithConfig:config theme:nil];
// Display the media picker view controller.
[self presentViewController:mediaPickerViewController animated:YES completion:nil];
The selection result will be called back through the completion block. The following is a sample result:
mediaPickerViewController.completion = ^(UGCKitResult *result) {
if (result.error) {
// Error.
[self showAlertWithError:error];
} else {
if (result.cancelled) {
// User cancelled shooting and left the picker view.
[self dismissViewControllerAnimated:YES completion:nil];
} else {
// Video edited and saved successfully. Use the result for subsequent processing.
[self processEditedVideo:result.media];
}
}
}
ClippingUGCKitCutViewController
provides the video clipping feature. As with the editing API, you need to pass in a media project when instantiating the controller and process clipping results in completion
.
UGCKitMedia *media = [UGCKitMedia mediaWithVideoPath:@"<#video path#>"];
UGCKitCutViewController *cutViewController = [[UGCKitCutViewController alloc] initWithMedia:media theme:nil];
cutViewController.completion = ^(UGCKitResult *result) {
if (!result.cancelled && !result.error) {
[self editVideo:result.media];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
[self.navigationController pushViewController: cutViewController]
Read the documents below to learn more about different modules of the SDK.
Was this page helpful?