This topic describes how to integrate ApsaraVideo Player SDK for iOS.
Environment requirements
Item | Description |
Operating system | iOS 8.0 or later. |
Development tool | We recommend that you use Xcode. The procedures described in this topic are based on Xcode. To download Xcode, visit Mac App Store. |
Prerequisites
A license for ApsaraVideo Player SDK is registered and the license file
AliVideoCert-********.crt
is obtained. For more information, see Obtain a license.The package for ApsaraVideo Player SDK for iOS and the source code of a demo are downloaded. We recommend that you download the latest versions of the SDK and demo. For more information about the download links, see SDK overview and download.
The following table describes the folders or files in the SDK package after the package is decompressed.
Folder or file | Description |
demo | The source code of the demo for ApsaraVideo Player SDK for iOS. |
doc | The API references for ApsaraVideo Player SDK for iOS. |
sdk | The frameworks for ApsaraVideo Player SDK for iOS. By default, only the ARM_SIMULATOR folder is provided. The ARM_SIMULATOR folder contains bitcode and simulators. If you do not want to enable bitcode or do not require simulators, run the following command to generate and download the corresponding SDK file:
|
ReleaseNote | The release notes for ApsaraVideo Player SDK for iOS. |
The following table describes the files that are generated after you run the sh createMoreKindsOfArch.sh
command.
File | Description |
ARM | The folder that contains bitcode but does not contain simulators. |
ARM_NO_BITCODE | The folder that does not contain bitcode or simulators. |
ARM_SIMULATOR | The folder that contains bitcode and simulators. |
The following table describes the framework files.
Framework | Description |
alivcffmpeg.framework | The framework that serves as the underlying dependency of the player. This framework is required. |
AliyunMediaDownloader.framework | The framework for offline download. This framework is optional. |
AliyunPlayer.framework | The player framework. This framework is required. |
artcSource.framework | An AAR package that supports the Alibaba Real-Time Communication (ARTC) protocol. This package is optional. |
artpSource.framework | An AAR package that supports the Alibaba Real-time Transport Protocol (ARTP) protocol. This package is optional. The dependency on this framework is removed in ApsaraVideo Player SDK for iOS V5.4.5.0. |
RtsSDK.framework | The framework that supports RTS. This framework is optional. |
AlivcConan | The dependency on this framework is removed in ApsaraVideo Player SDK for iOS V5.3.0. |
Usage notes
When you package your application files, dSYM files are used to symbolicate crash reports.
AlivcFFmpeg and AliyunPlayer are required when you use ApsaraVideo Player SDK for iOS. You can view header files in the directory of AliyunPlayer.framework.
If you want to integrate both the short video SDK and ApsaraVideo Player SDK, make sure that you import the correct version of AlivcFFmpeg. Otherwise, you cannot use the features that are provided by the short video SDK or ApsaraVideo Player SDK. For more information, see AlivcFFmpeg dependencies.
Specific features of ApsaraVideo Player SDK for iOS may not run as expected on a simulator. After you integrate ApsaraVideo Player SDK for iOS, we recommend that you use an iPhone for debugging.
A simulator is included in the installation package of ApsaraVideo Player SDK for iOS. You can use the simulator to debug code. If you want to publish the application, do not use SDKs that contain simulators. Otherwise, the application may fail to be submitted to App Store.
Integrate the SDK by using CocoaPods (Recommended)
Use CocoaPods statements to integrate ApsaraVideo Player SDK for iOS. Sample code:
NoteIf you want to integrate both the short video SDK and ApsaraVideo Player SDK, replace
AliPlayerSDK_iOS
in the following code withAliPlayerPartSDK_iOS
.AliPlayerPartSDK_iOS
does not contain the FFmpeg framework. This prevents conflicts with the FFmpeg framework of the short video SDK for iOS.ruby platform:ios, '8.0' target 'yourProject' do pod 'AliPlayerSDK_iOS' end
Optional: If you want the player to support the ARTC protocol or play RTS streams, add the pod dependencies as required. Sample code:
NoteMake sure that the version number of the SDK is correct. Otherwise, an error is reported and the dependencies fail to be added.
ruby platform:ios, '8.0' target 'yourProject' do pod 'AliPlayerSDK_iOS', '5.4.7.1' pod 'AliPlayerSDK_iOS_ARTC', '5.4.7.1' pod 'RtsSDK', '2.2.0' // This version number is for reference only. For more information about the latest version of the RTS SDK, see Download SDKs. end
Integrate the SDK by adding local files
If you want to integrate both the short video SDK and ApsaraVideo Player SDK, only one AlivcFFmpeg is required. Make sure that you import the correct version of AlivcFFmpeg.
In the Xcode project, click the General tab.
Add the frameworks of ApsaraVideo Player SDK for iOS to the Frameworks, Libraries, and Embedded Content section. Select Embed & Sign in the Embed column for these frameworks.
Click the Build Settings tab.
In the Search Paths section, set the Framework Search Paths parameter to the path in which the framework files are stored.
Configure the license
You must perform the following operations to configure the license for ApsaraVideo Player SDK for iOS V5.4.7.1 and later versions before you use the SDK.
You can use ApsaraVideo Player SDK for Android for free. The validity period of the SDK license is one year. By default, the system automatically renews the license free of charge after the license expires. After the SDK license is renewed, the system updates your local certificate. We recommend that you integrate the latest local certificate when you publish the new version of your application. You can obtain the latest certificate in the ApsaraVideo VOD console. For more information, see Manage licenses.
After you configure the license, check the log. If no license-related errors are reported, the license is configured correctly.
The configured license file and license key must be used for the application specified by BundleID. If the license file or license key does not match the application, the authentication fails.
In the Xcode project, choose
. Then, copy the license fileAliVideoCert-********.crt
to the Xcode project. We recommend that you store the file in the AppSupportFiles directory. You can also place it in the sandbox directory or other directories that you prefer.Add the following fields to the Info.plist file.
Set the first key to
AlivcLicenseKey
and the value to the value of LicenseKey.Set the second key to
AlivcLicenseFile
and the value to the path in which the license file is stored.
<key>AlivcLicenseKey</key> <string>Wo8s*******************</string> <key>AlivcLicenseFile</key> <string>license.crt</string>
FAQ
What do I do if an error message indicating that an AlivcFFmpeg or AlivcConan conflict exists is returned when I reference a third-party SDK in my project?
Solutions:
Conflict with symbol of AlivcConan: remove AlivcConan from Linked Frameworks and Libraries since AlivcConan is no longer needed in V5.3.0 or later. AlivcConan is optional for application links.
Conflict with symbol of AlivcFFmpeg: Retain only one AlivcFFmpeg and delete the extra AlivcFFmpeg dependencies. AlivcFFmpeg is a custom dependency developed by Alibaba Cloud based on FFmpeg and a key part of ApsaraVideo Player SDK. We recommend that you delete the AlivcFFmpeg dependency for the third-party SDK and retain the AlivcFFmpeg dependency for ApsaraVideo Player SDK. However, this may cause errors in the third-party player.
For more information about the issues that may occur when you use ApsaraVideo Player SDK and corresponding solutions, see FAQ about ApsaraVideo Player.