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 a Xcode development environment. You can download Xcode from 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 ApsaraVideo Player SDK for iOS package is downloaded before you integrate the SDK by using on-premises files. The SDK package contains ApsaraVideo Player SDK for iOS and the source code of a demo. We recommend that you use the latest version of ApsaraVideo Player SDK for iOS. For information about how to download the latest version of the SDK, see SDK overview and download.
The following table describes the folders or files in the SDK folder that is generated after the SDK 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. |
ARM_SIMULATOR_NO_BITCODE | The folder that contains simulators but not bitcode. |
The following table describes the framework files that the SDK contains.
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 | The framework that supports the Alibaba Real-Time Communication (ARTC) protocol. This framework is optional. |
RtsSDK.framework | The framework that supports RTS. This framework is optional. |
aemFilter.framework | The framework for audio enhancement. This framework is optional. |
libPluginSR.framework | The framework for super-resolution model. This framework is optional. |
normalsrFilter.framework | The framework for super-resolution model. This framework is optional. |
mpfFilter.framework | The framework for super-resolution model. This framework is optional. |
srFilter.framework | The framework for super-resolution model. This framework is optional. |
vfiFilter.framework | The framework for video frame insertion. This framework is optional. |
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 find header files in AliyunPlayer.framework.
If you want to integrate both the short video SDK and ApsaraVideo Player SDK, make sure to import the correct version of AlivcFFmpeg. Otherwise, you will not be able to use the features provided by the SDKs. 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 # ApsaraVideo Player SDK. We recommend that you use the latest version. For more information, visit the official website: https://help.aliyun.com/zh/vod/developer-reference/sdk-overview-and-download?spm=a2c4g.11186623.0.0.63cde7ea3nNYgA#section-v53-2oj-xfd. 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 will be reported and the dependencies will fail to be added.
ruby platform:ios, '8.0' target 'yourProject' do # ApsaraVideo Player SDK. We recommend that you use the latest version. For more information, visit the official website: https://help.aliyun.com/zh/vod/developer-reference/sdk-overview-and-download?spm=a2c4g.11186623.0.0.63cde7ea3nNYgA#section-v53-2oj-xfd. pod 'AliPlayerSDK_iOS' # Real-time Streaming (RTS) SDK. We recommend that you use the latest version. For more information, visit the official website: https://help.aliyun.com/zh/live/user-guide/pull-streams-over-rts-on-ios?spm=a2c4g.11186623.help-menu-29949.d_2_11_0_6_1.5edb659e1iPsz6. pod 'AliPlayerSDK_iOS_ARTC', '6.19.0' pod 'RtsSDK', '2.6.3' # 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.
Bind a license to an iOS application
Configure a license.
Recommended. Copy the license file
AliVideoCert-********.crt
to the AppSupportFiles directory of your Xcode project. You can also copy it to the sandbox directory or other directories that you prefer. Select the current project in Target Membership.Open the Info.plist file. Set the AlivcLicenseKey and AlivcLicenseFile parameters for the global environment, or the AlivcLicenseKey_SEA and AlivcLicenseFile_SEA parameters for the international environment to the license key and license file path you obtained when applying for the license.
ImportantIf you want to use ApsaraVideo Player SDK V6.14.0 or later on the Alibaba Cloud international site (alibabacloud.com), you must configure a license for the international environment. If you do not use ApsaraVideo Player SDK, you can configure a license for the global environment.
You can bind two licenses to your application at the same time: one for the global environment and one for the international environment. Then, you can specify the environment to use the player by configuring the service environment for ApsaraVideo Player SDK each time you start your application. You cannot switch the environment when the player is running.
// Configure a license for the global environment. This is the default configuration. <key>AlivcLicenseFile</key> <string>XXX</string> <key>AlivcLicenseKey</key> <string>foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****</string> // Configure a license for the international environment and add _SEA to the end of the license name. <key>AlivcLicenseFile_SEA</key> <string>XXX</string> <key>AlivcLicenseKey_SEA</key> <string>f6b6efoIVziMaUHaRqgDyhb8fcf014af39535d0a32072****</string>
Configure a service environment for ApsaraVideo Player SDK. This step is required if you use the Alibaba Cloud international site (alibabacloud.com).
ApsaraVideo Player SDK V6.14.0 and later allows you to select a service environment. By default, the global environment is configured for ApsaraVideo Player SDK V6.14.0 and later. Users of the Alibaba Cloud international site (alibabacloud.com) cannot use the global environment. If you want to use the Alibaba Cloud international site (alibabacloud.com), you must update the service environment to the international environment for ApsaraVideo Player SDK by using the following method each time you start your application. Otherwise, authentication will fail for the license that authorizes your application to use ApsaraVideo Player SDK. You can ignore this step in scenarios such as using ApsaraVideo Player SDK of a version that is earlier than V6.14.0 or using other SDKs.
// When you use the Alibaba Cloud international site (alibabacloud.com), make sure that you have updated the service environment before calling an API operation of the player. This ensures that all subsequent services will run on the Alibaba Cloud international site (alibabacloud.com). // Update the service environment to the international environment by calling the following operation. You cannot alter the environment when the player is running. AlivcBase.EnvironmentManager.globalEnvironment = ENV_SEA;
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?
The following section describes the solutions to the preceding error:
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.
What do I do if a sandBox error occurs?
The following section describes the error:
The following section describes the solutions to the preceding error:
Set User Script SandBoxing in UserSetting to NO.
For more information about the issues that may occur when you use ApsaraVideo Player SDK and corresponding solutions, see FAQ about players.