This document explains how to quickly integrate AliPlayerKit into your iOS project.
AI-friendly tip: This is a structured document with clear steps, making it ideal for AI parsing and execution. It can be used as a Skill to assist in your development workflow. We recommend using AI assistance to integrate AliPlayerKit.
Integration overview
Make sure you have visited AliPlayerKit and downloaded the project.
AliPlayerKit provides two integration options. Choose one based on your business needs:
Integration option | Description | Use cases |
component-level integration | Integrate the | Use this option if you need a custom player UI or more flexible control over playback behavior. |
scene-level integration | Integrate the | Use this option to quickly implement standard playback scenarios. |
Scene-level integration builds upon component-level integration. Therefore, you must complete the component-level integration first.
Prerequisites
Development environment
Item | Minimum requirement | Description |
iOS deployment target | 9.0+ | The minimum version declared in the Podspec. |
Xcode | 15.0+ | The latest stable version is recommended. |
CocoaPods | 1.13.0+ | Dependency management tool. |
Development language | Objective-C | Swift projects can call it through a bridging header. |
Architecture | arm64 | To run the app on a physical device. |
For Swift projects, follow the Swift-Call-OC-Exampleguide to integrate and use PlayerKit.
License
You must have a player license certificate and License Key for the ApsaraVideo Player SDK. For details, see Manage License.
If the license is not configured correctly, the player will not work properly and may cause a black screen during playback.
Option 1: Component-level integration
The PlayerKit core module provides an out-of-the-box, configurable player UI component that covers basic playback and common interactive features.
Step 1: Copy the module to your project
Copy the PlayerKit/ directory to your project's directory (at the same level as your Podfile or in a suitable subdirectory):
YourProject/
├── YourApp/
├── PlayerKit/ # ← Copy this directory
│ ├── PlayerKit.podspec
│ ├── Source/
│ └── Resources/
└── PodfileStep 2: Configure the Podfile
In your Podfile, reference PlayerKit using its local path:
platform :ios, '11.0'
target 'YourApp' do
use_frameworks!
# Core component (required, referenced by local path)
pod 'PlayerKit', :path => './PlayerKit'
# Underlying player SDK (required)
pod 'AliPlayerSDK_iOS', '~> 7.15.0'
# RTS for ultra-low latency live streaming (optional, for live streaming scenarios only)
# pod 'AliPlayerSDK_iOS_ARTC', '~> 7.15.0'
# pod 'RtsSDK', '~> 7.12.0'
endPlayerKit.podspec declares dependencies on AliPlayerSDK_iOS and SDWebImage, which are automatically installed when you run pod install. AliPlayerSDK_iOS provides video decoding and rendering capabilities. SDWebImage is used to load the cover image. If your project already uses SDWebImage, check for version compatibility.
Step 3: Install dependencies
pod install
open YourApp.xcworkspaceAfter using CocoaPods, open your project with .xcworkspace, not .xcodeproj.
Step 4: Configure the license
The player SDK requires a valid license to work. See Manage License to obtain and configure your license.
Make sure the license is registered before you call [AliPlayerKit setup].
Step 5: Global initialization
This method should be called only once during the application lifecycle:
#import <AliPlayerKit/AliPlayerKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// (Optional) Global SDK configuration, such as setOption
// [AliPlayerKit setOnGlobalInitBlock:^{
// Global configuration is executed only once after setup
// }];
// Initialize AliPlayerKit
[AliPlayerKit setup];
return YES;
}import AliPlayerKit
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// (Optional) Global SDK configuration
// AliPlayerKit.setOnGlobalInitBlock {
// Global configuration is executed only once after setup
// }
// Initialize AliPlayerKit
AliPlayerKit.setup()
return true
}[AliPlayerKit setup]usesdispatch_onceinternally to ensure idempotence. It is safe to call multiple times; subsequent calls are ignored.setOnGlobalInitBlock:must be set beforesetupto apply global SDK settings.You can check the initialization status by calling
[AliPlayerKit isInitialized].
Step 6: Verify the integration
Use the following checklist to verify the integration:
pod installcompletes successfully without dependency conflicts.The license is configured correctly.
[AliPlayerKit setup]is called in AppDelegate.The project builds successfully (Cmd + B) without linker errors.
Option 2: Scene-level integration
The scene level (PlayerKitScenes) builds on the component level to provide standard playback solutions for specific business scenarios. Each scene module is independent and can be imported as needed.
Before you integrate the scene level, complete all steps in Option 1: Component-level integration.
Step 1: Copy the module to your project
Copy the PlayerKitScenes/ directory to your project, at the same level as PlayerKit/:
YourProject/
├── YourApp/
├── PlayerKit/ # Component level (already copied)
├── PlayerKitScenes/ # ← Copy this directory
│ ├── PlayerKitScenes.podspec
│ ├── SceneCommon/
│ ├── SceneLongVideo/
│ ├── SceneShortVideo/
│ ├── SceneLive/
│ └── ScenePlaylist/
└── PodfileStep 2: Configure the Podfile
In your Podfile, reference PlayerKitScenes using its local path:
target 'YourApp' do
use_frameworks!
# Core component (required)
pod 'PlayerKit', :path => './PlayerKit'
pod 'AliPlayerSDK_iOS', '~> 7.15.0'
# Playback scene solutions (import as needed)
pod 'PlayerKitScenes', :path => './PlayerKitScenes'
# Or, select individual scenes as needed:
# pod 'PlayerKitScenes/SceneLongVideo', :path => './PlayerKitScenes'
# pod 'PlayerKitScenes/SceneShortVideo', :path => './PlayerKitScenes'
# pod 'PlayerKitScenes/SceneLive', :path => './PlayerKitScenes'
# pod 'PlayerKitScenes/ScenePlaylist', :path => './PlayerKitScenes'
endScene module descriptions:
Scene module | Pod subspec | Description |
SceneCommon | PlayerKitScenes/SceneCommon | The common module for scenes. It is automatically included as a base dependency. |
SceneLongVideo | PlayerKitScenes/SceneLongVideo | For medium and long-form video scenarios. |
SceneShortVideo | PlayerKitScenes/SceneShortVideo | For short-form video scenarios. |
SceneLive | PlayerKitScenes/SceneLive | For live streaming scenarios. |
ScenePlaylist | PlayerKitScenes/ScenePlaylist | For playlist playback scenarios. |
Step 3: Install and verify
pod installIf your project builds successfully, the scene-level integration is complete.
SDK upgrade
AliPlayerKit depends on the following underlying SDKs:
SDK | Description |
AliPlayerSDK_iOS | Alibaba Cloud Player SDK, which provides core playback capabilities such as video decoding, rendering, and playback control. |
RtsSDK | Alibaba Cloud RTS SDK, which provides ultra-low latency live streaming playback (optional). |
Version information
At runtime, call
[AliPlayerKit getSdkVersion]to get the underlying SDK version number.Call
[AliPlayerKit getPlayerKitVersion]to get the AliPlayerKit component version number.
Upgrade steps
Confirm version compatibility.
Before upgrading, review the SDK release history and changelog to check if the target version contains breaking changes.
Modify the version number in your Podfile.
pod 'AliPlayerSDK_iOS', '~> x.x.x' # Replace with the target version # RTS (if you use live streaming scenarios) # pod 'AliPlayerSDK_iOS_ARTC', '~> x.x.x' # pod 'RtsSDK', '~> x.x.x'Run the update command.
pod update AliPlayerSDK_iOSVerify the upgrade.
The project builds successfully without linker errors.
Verify core playback functions: play, pause, seek, playback speed, etc.
Verify specific playback scenarios, such as ultra-low latency live streaming with RTS.
After an upgrade, we recommend recording the version numbers before and after the upgrade. This helps with future troubleshooting and version tracking.
FAQ
License issues
Problem: The player reports a license error or shows a black screen.
Common causes include an incorrectly added certificate file, a mismatched License Key, a Bundle ID that is inconsistent with the one bound to the license, or an expired license. For details, see Manage License.
Dependency conflicts
Problem: pod install fails with a dependency conflict.
Troubleshooting steps: This conflict can occur if your project and PlayerKit depend on different versions of SDWebImage. Try running pod update to resolve the conflict. If the issue persists, run pod repo update to refresh your local repository index before trying again.
Initialization issues
Problem: Playback does not work correctly after you call [AliPlayerKit setup].
Troubleshooting steps:
Ensure the call is made in
application:didFinishLaunchingWithOptions:withinAppDelegate.Confirm that the license is configured correctly. For details, see Manage License.
Call
[AliPlayerKit isInitialized]to confirm that the initialization was successful.The
setupmethod is idempotent (usingdispatch_once). Repeated calls are safe and do not throw exceptions.If you need to inject global SDK configurations, confirm that
setOnGlobalInitBlock:is set beforesetupis called.
Debugging with logs
If you encounter playback issues, you can enable debug logs to help with troubleshooting:
// Enable debug mode
[AliPlayerKit setDebugModeEnabled:YES];
// Set the log level to Verbose for the most detailed output
[AliPlayerKit setLogLevel:LogLevelVerbose];For details on how to use the logging system, see Logging System.