Prerequisites
- The short video SDK license is obtained and activated. For more information, see Obtain and use a license of the short video SDK.
- The short video SDK for iOS is integrated. For the short video SDK 3.29.0 or later, you need to configure the license before you register the SDK. For more information, see Integrate the short video SDK for iOS.
Import the header file
The header file of the short video SDK defines the specifications that you need to comply with when you use the methods of the short video SDK. To use the short video SDK, you must import the header file first.#import <AliyunVideoSDKPro/AliyunVideoSDKPro.h>
Register the short video SDK for iOS
If you use the short video SDK 3.29.0 or later, you need to register the SDK after you start the application. Otherwise, the short video SDK cannot be used. The following code shows an example on how to register the short video SDK for iOS.
// Register the short video SDK 3.30.0 or later.
NSError *error = [AliyunVideoSDKInfo registerSDK]; // If nil is returned, the registration is successful.
// In most cases, registration failures result from license integration issues. We recommend that you add an Assert function in your code. This way, if an error occurs during SDK registration, the system returns an error message and provides suggestions on how to fix the error.
NSAssert2(error == nil, @"SDK registration failed. %@;%@", error.localizedDescription, error.localizedRecoverySuggestion);
// Register the short video SDK 3.29.0.
// Rename the license file to license.crt and add it to your application project. Then, use the following code to obtain the directory in which the license file is stored.
NSString *licenseFilePath = [NSBundle.mainBundle pathForResource:@"license" ofType:@"crt"];
// Register the SDK by using the obtained license key and license file path.
[AliyunVideoSDKInfo registerSDKWithLicenseKey:LicenseKey licenseFile:licenseFilePath];
AliyunVideoLicense *license = AliyunVideoLicenseManager.CurrentLicense;
// Obtain the authentication results for the short video SDK 3.30.0 or later.
AliyunVideoLicenseManager.EventDelegate = self; // For more information, see the description of AliyunVideoLicenseEventDelegate.
AliyunVideoLicenseResultCode code = [AliyunVideoLicenseManager check];
[AliyunVideoLicenseManager Refresh:^(AliyunVideoLicenseRefreshCode code){
// The information about the license verification result.
}];
Specify the resource package path
If you integrate the short video SDK by using the least dependency integration method but you want to add the AliyunVideoSDKPro.bundle resource package, you can perform the following steps to automatically download the resource package when you run the application. The resource package is added to the short video SDK after the download is complete.
- Upload the resource package to the cloud. For example, you can upload the resource package to an Object Storage Service (OSS) bucket.
- Check whether the resource package exists when the application is started. If the resource package does not exist, the system downloads the resource package to your local device. If the resource package already exists, proceed to the next step.
- Specify the path in which the resource package is stored. Sample code:
[AliyunVideoSDKInfo setSDKBundlePath:@"The path in which the resource package is stored on the local device"];
Log output
// The following levels of logs are supported.
typedef NS_ENUM(NSInteger, AlivcLogLevel)
{
AlivcLogClose = 1,
AlivcLogVerbose,
AlivcLogDebug,
AlivcLogInfo,
AlivcLogWarn,
AlivcLogError,
AlivcLogFatal
};
// Specify the level of the logs to be generated.
[AliyunVideoSDKInfo setLogLevel:AlivcLogDebug];
Query the version information
[AliyunVideoSDKInfo printSDKInfo];
NSString *version = [AliyunVideoSDKInfo version]; // The version number.
NSString *module = [AliyunVideoSDKInfo module]; // The version type.
int moduleCode =[AliyunVideoSDKInfo versionCode]; // The code of the version type.
NSString *buildId =[AliyunVideoSDKInfo videoSDKBuildId]; // The bundle ID of the version.
NSLog(@"\n==============\nVERSION:%@\nBUILD_ID:%@\nMODULE:%@\nMODULE_CODE:%d\n==============", version, buildId, module, moduleCode);