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 the license.
-
In the Xcode project, copy the certificate file
AliVideoCert-********.crt
to the project, preferably to the AppSupportFiles directory. You can also place it in the sandbox or other paths. Ensure it's included in the Target Membership. -
Open Info.plist and update AlivcLicenseKey, AlivcLicenseFile (China site environment), AlivcLicenseKey_SEA, AlivcLicenseFile_SEA (international site environment), or AlivcLicenseKey_OVERSEA, AlivcLicenseFile_OVERSEA (new international site environment) with the license key and file path obtained when you apply for a license.
Important-
For Alibaba Cloud international site (alibabacloud.com) users who need to use ApsaraVideo Player SDK:
-
For SDK version 6.14.0 or later, configure the international site environment or new international site environment license.
-
For SDK version 7.0.0 or later, it's recommended to configure the new international site environment license for enhanced service support.
-
If not using ApsaraVideo Player SDK, only the China site environment license is necessary.
-
-
You can bind two licenses at once (one international site environment license and one China site environment license). After each app launch, set the player's runtime environment by configuring the service environment of ApsaraVideo Player SDK. The environment cannot be changed during player operation.
// License configuration for the Chinese mainland and Hong Kong (China), Macao (China), and Taiwan (China) (default configuration) <key>AlivcLicenseFile</key> <string>XXX</string> <key>AlivcLicenseKey</key> <string>foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****</string> // License configuration for Global (excluding the Chinese mainland and Hong Kong (China), Macao (China), and Taiwan (China)), manually add _SEA at the end <key>AlivcLicenseFile_SEA</key> <string>XXX</string> <key>AlivcLicenseKey_SEA</key> <string>f6b6efoIVziMaUHaRqgDyhb8fcf014af39535d0a32072****</string> // License configuration for the new Global (excluding the Chinese mainland and Hong Kong (China), Macao (China), and Taiwan (China)), manually add _OVERSEA at the end <key>AlivcLicenseFile_OVERSEA</key> <string>XXX</string> <key>AlivcLicenseKey_OVERSEA</key> <string>f6b6efoIVziMaUHaRqgDyhb8fcf014af39535d0a32072****</string>
-
-
-
Configure the service environment of ApsaraVideo Player SDK (necessary for the international site or new international site environment).
ApsaraVideo Player SDK V6.14.0 and later supports selecting a service environment. The ApsaraVideo Player SDK V6.14.0 and later is set to the China site environment by default. If you need to use the international site environment (currently, users of the Alibaba Cloud international site (alibabacloud.com) can only use the international site environment), you must update the configuration of ApsaraVideo Player SDK to the international site or new international site environment after each app startup. Otherwise, the license of ApsaraVideo Player SDK will fail to be authenticated. You can skip this step in other versions and scenarios where SDKs are used.
// When you use the Global (excluding the Chinese mainland and Hong Kong (China), Macao (China), and Taiwan (China)) environment, make sure that you call the following operation to update the default configuration to the international site environment before you call any player API to ensure that all subsequent services run in the international site environment // 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; // Update the service environment to the new international environment by calling the following operation. You cannot alter the environment when the player is running. AlivcBase.EnvironmentManager.globalEnvironment = ENV_GLOBAL_OVERSEA;
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.