教你1天搭建自己的“微视”

img

第二步 工程配置iOS或者Android

工程配置iOS

Xcode Project Settings I. Supported Platform

SDK supports iOS 8.0 or above.

II. Development Environment

Xcode 8 or above

OS X 10.10 or above

III. Xcode Project Settings

A simple iOS Application project is shown below to illustrate how to configure SDK in an Xcode project.

1. Copy SDK File

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.

2. Add Framework

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:

3. Add Header File

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" IV. Verification

Next, call the SDK API in the codes of HelloSDK to obtain SDK version information and verify whether the project is correctly configured.

1. Reference the Header File

Reference the SDK header file at the beginning of ViewController.m:

#import "TXLiteAVSDK_UGC/TXLiveBase.h" 2. Add Calling Code

Add the following code to the viewDidLoad method:

- (void)viewDidLoad { [super viewDidLoad]; // Print SDK version information NSLog(@"SDK Version = %@", [TXLiveBase getSDKVersionStr]); } 3. Compile and Run

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.

Printing LOG

Configure whether to print log in the console and set the log level in TXLiveBase. Codes are described as follows:

setConsoleEnabled Configure whether to print the output of SDK in the Xcode console.

setLogLevel Configure whether to allow SDK to print local log. By default, SDK writes log to the Documents/logs folder of the current App. For technical support, you are recommended to enable the sub-switch and provide the log file after a problem occurs. Thank you for your support.

View log file To reduce the storage volume of logs, Mini LVB SDK encrypts the log files stored locally and limits the number of logs. Therefore, you need to use the log Decompression Tool to view the text content of log.

[TXLiveBase setConsoleEnabled:YES]; [TXLiveBase setLogLevel:LOGLEVEL_DEBUG];

工程配置Android

1. System Requirement

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.

2. Development Environment

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:

Android NDK: android-ndk-r12b

Android SDK Tools: android-sdk_25.0.2

minSdkVersion: 15

targetSdkVersion: 21

Android Studio (Android Studio is recommended, but you can also use Eclipse + ADT)

3. Integration Guide (aar) 3.1 New Project 3.2 Copy Files

Put the aar package under the project libs directory

3.3 Project Configuration

Add the code that references aar package to build.gradle under the project app directory:dependencies {

​ compile fileTree(dir: 'libs', include: ['*.jar'])

​ // Import the short video SDK aar

​ compile(name: 'LiteAVSDK_UGC_3.4.1757', ext: 'aar')

}

Add flatDir to build.gradle under the project directory, and specify the local library in it:allprojects {

​ repositories {

​ jcenter()

​ flatDir {

​ dirs 'libs'

​ }

​ }

}

Specify ndk-compatible architecture in defaultConfig of build.gradle under the project directory: defaultConfig {

​ applicationId "com.tencent.liteav.demo"

​ minSdkVersion rootProject.ext.minSdkVersion

​ targetSdkVersion rootProject.ext.targetSdkVersion

​ versionCode 1

​ versionName "2.0"

​ ndk {

​ abiFilters "armeabi", "armeabi-v7a"

​ }

​ }

Finally, compile Rebuild Project.

4 Integration Guide (jar) 4.1 Library Description

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  
4.2 Copy Files

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsfpyj.html