工程配置iOS
A simple iOS Application project is shown below to illustrate how to configure SDK in an Xcode project.
In this example, an iOS project named HelloSDK is created, and the downloaded TXLiteAVSDK_UGC.framework
is copied to the project directory. The figure below shows the directory structure.
Add TXLiteAVSDK_UGC.framework
to the project. At the same time, add the following dependent libraries:
libz.tbd Accelerate.framework Bugly.framework
After you've added the above libraries, the project dependency shows as follows:
Add the search path for header file to "Build Settings" -> "Search Paths" -> "User Header Search Paths". Please note that this operation is not required. If you do not add the header file search path for TXLiteAVSDK_UGC, "TXLiteAVSDK_UGC/" needs to be added before the SDK-related header file when the header file is referenced, as shown below:
#import "TXLiteAVSDK_UGC/TXUGCRecord.h"
Next, call the SDK API in the codes of HelloSDK to obtain SDK version information and verify whether the project is correctly configured.
Reference the SDK header file at the beginning of ViewController.m:
#import "TXLiteAVSDK_UGC/TXLiveBase.h"
Add the following code to the viewDidLoad method:
- (void)viewDidLoad {
[super viewDidLoad];
// Print SDK version information
NSLog(@"SDK Version = %@", [TXLiveBase getSDKVersionStr]);
}
If all of the above steps are performed correctly, the HelloSDK project can be compiled successfully. Run the App in the Debug mode. SDK version information is output in Xcode's Console pane.
2017-09-26 16:16:15.767 HelloSDK17929:7488566 SDK Version = 3.4.1761
Now, the project configuration is completed.
Configure whether to print log in the console and set the log level in TXLiveBase. Codes are described as follows:
[TXLiveBase setConsoleEnabled:YES];
[TXLiveBase setLogLevel:LOGLEVEL_DEBUG];
工程配置Android
SDK can run on Android 4.0.3 (API 15) or above. However, hardware encoding can be enabled only on Android 4.3 (API 18) or above.
SDK development environment is described below. The App development environment does not need to be consistent with that of SDK, but it must be compatible with:
Put the aar package under the project libs directory
Decompress LiteAVSDK_UGC_3.4.1757.zip to get the libs directory, which mainly includes a jar file, as shown below:
jar file | Description |
---|---|
liteavsdk.jar | Mini LVB SDK android core library |
For library related to the upload of short videos, jar files and a so file for uploading short videos can be found in the Demo\app\libs directory, as shown below:
jar file | Description |
---|---|
sha1utils.jar | JAR package that implements SHA calculation of files to be uploaded. This component is used for short video upload (TXUGCPublish) feature |
cos-sdk-android.1.4.3.11.jar | File upload package of Tencent Cloud COS. This component is used for short video upload (TXUGCPublish) feature |
okio-1.6.0.jar | An excellent open source network I/O component |
okhttp-3.2.0.jar | An excellent open source HTTP component |
so file | Description |
---|---|
libTXSHA1.so | JAR package that implements SHA calculation of files to be uploaded. This component is used for short video upload (TXUGCPublish) feature |
If no jni loading path is previously specified in your project, we recommend that you put the jar package and so library under the /src/main/jniLibs directory, which is the default jni loading directory of android studio.
Add the code that references jar package and so library to build.gradle under the project app directory:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Import Tencent Cloud LVB SDK jar
compile fileTree(dir: 'src/main/jniLibs', includes: ['*.jar'])
}
Configure App permissions in AndroidManifest.xml. Generally, video Apps require the following permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.Camera"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
Call the SDK API in the project to get SDK version information and verify whether the project is correctly configured.
Reference the class of SDK in MainActivity.java:
import com.tencent.rtmp.TXLiveBase;
Call the API getSDKVersioin in onCreate to get version number:
String sdkver = TXLiveBase.getSDKVersionStr();
Log.d("liteavsdk", "liteav sdk version is : " + sdkver);
The demo project can be compiled successfully if all of the above steps are correctly performed. If you run the project, you can see the following log information in logcat:
09-26 19:30:36.547 19577-19577/ D/liteavsdk: liteav sdk version is : 3.4.1757
<a name="online_so"> </a>
Configure whether to print log in the console and set the log level in TXLiveBase. Codes are described as follows:
TXLiveBase.setConsoleEnabled(true);
TXLiveBase.setLogLevel(TXLiveConstants.LOG_LEVEL_DEBUG);
If the following errors occur when you compile/run the project after importing the SDK into it:
Caused by: android.view.InflateException:
Binary XML file #14:Error inflating class com.tencent.rtmp.ui.TXCloudVideoView
Find the problem by following the steps below:
After a file is published, no error message or callback response is returned. The following appears when the log is printed:
TaskManager: ExecutionException
This is because the libTXSHA1.so used for upload has not been properly integrated into the project. For more information, please see Integration Guide.
如果你是iOS开发,可参考视频录制(iOS)
如果你是Android开发,可参考视频录制(Android)
如果你是iOS开发,可参考视频编辑(iOS)
如果你是Android开发,可参考视频编辑(Android)
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。