Integrate the SDK
Learn the requirements and limits for integrating ApsaraVideo Player SDK for Flutter into your project.
Environment requirements
|
Category |
Description |
|
Flutter version |
Supports Flutter 3.22.2, channel stable. |
|
Dart version |
Supports Dart 3.4.3 |
|
OS version |
Android 6.0+ |
|
Phone chip |
Required architectures: armeabi-v7a, arm64-v8a |
|
Development tools |
Use Android Studio or Visual Studio Code. |
SDK downloads
The ApsaraVideo Player SDK for Flutter must match your Flutter SDK version. For example, Player SDK 5.4.0 requires Flutter SDK 2.0+. Check the Flutter SDK release history for compatibility details.
-
Flutter SDK: Flutter SDK
-
Latest ApsaraVideo Player SDK for Flutter: ApsaraVideo Player SDK
-
ApsaraVideo Player SDK for Flutter plugin (for patch updates): ApsaraVideo Player SDK for Flutter plugin
Project description
The Flutter player SDK wraps the native ApsaraVideo Player SDKs for Android and iOS. The demo provides the source code as a dependency you can add to your project.
Project folder structure:
Folder details:
|
File name |
Description |
Required |
|
android |
Android native code and player SDK. |
Yes |
|
ios |
iOS native code and player SDK. |
Yes |
|
lib |
Flutter API code. |
Yes |
|
example |
Flutter player demo. |
No |
The SDK supports both live streaming and playback. To use playback only, switch the SDK kernel from the all-in-one version to the playback-only version. The following examples use the demo project.
Android
-
Add the Alibaba Cloud Maven repository to the project-level build.gradle file.
maven { url "https://maven.aliyun.com/nexus/content/repositories/releases" } -
Replace the ApsaraVideo for MediaBox SDK (interactive stream) with the ApsaraVideo Player SDK.
Set the useAIOFramework variable in the android/build.gradle file.
If useAIOFramework = false, the playback-only SDK and RTS stream pulling for Android are used. If useAIOFramework = true, the Android version (interactive stream) is used, which supports stream ingest for live streaming, including Real-Time Streaming (RTS) and RTC-based co-streaming, and playback.
ImportantUpdate the kernel SDK version as needed. Latest versions: ApsaraVideo for MediaBox SDK, ApsaraVideo Player SDK, and RTS Stream Pulling.
dependencies { // Define the SDK kernel. def useAIOFramework = false def aio_sdk_version = "x.x.x" // Latest version of ApsaraVideo for MediaBox SDK (interactive stream). def player_sdk_version = "x.x.x" // Latest version of ApsaraVideo Player SDK. def rts_sdk_version = "x.x.x" // Latest version of the RTS component. // Select the SDK based on the value of useAIOFramework. if (useAIOFramework) { // ApsaraVideo for MediaBox SDK (interactive stream): Supports stream ingest for live streaming (including RTS and RTC-based co-streaming) and playback. implementation "com.aliyun.aio:AliVCSDK_InteractiveLive:$aio_sdk_version" } else { // ApsaraVideo Player SDK. implementation "com.aliyun.sdk.android:AliyunPlayer:$player_sdk_version-full" // (Optional) RTS component SDK. implementation "com.aliyun.rts.android:RtsSDK:$rts_sdk_version" // (Optional) The AlivcArtc bridge layer between the player and RTS. The version number must be the same as the player SDK version. This layer must be integrated together with the RTS component. implementation "com.aliyun.sdk.android:AlivcArtc:$player_sdk_version" } }
iOS
Set the useAIOFramework variable in flutter_aliplayer.podspec.
If useAIOFramework = false, the playback-only SDK and RTS stream pulling for iOS are used.
If useAIOFramework = true, the iOS version (interactive stream) is used, which supports stream ingest for live streaming, including Real-Time Streaming (RTS) and RTC-based co-streaming, and playback.
Update the kernel SDK version as needed. Latest versions: ApsaraVideo for MediaBox SDK, ApsaraVideo Player SDK, and RTS Stream Pulling.
# Define the SDK kernel.
useAIOFramework = false
# Define the SDK versions.
aio_sdk_version = 'x.x.x'
player_sdk_version = 'x.x.x'
rts_sdk_version = 'x.x.x'
# Select the SDK based on the value of useAIOFramework.
if useAIOFramework
s.subspec 'AliVCSDKFrameworks' do |ss|
# ApsaraVideo for MediaBox SDK (interactive stream): Supports stream ingest for live streaming (including RTS and RTC-based co-streaming) and playback.
ss.dependency 'AliVCSDK_InteractiveLive', aio_sdk_version
end
else
s.subspec 'AliPlayerSDKFrameworks' do |ss|
# Standalone ApsaraVideo Player SDK for iOS.
ss.dependency 'AliPlayerSDK_iOS', player_sdk_version
ss.dependency 'AliPlayerSDK_iOS_ARTC', player_sdk_version
ss.dependency 'RtsSDK', rts_sdk_version
end
end
Limits
The ApsaraVideo Player SDK for Android does not support emulators. Use a physical device for testing.
Integration procedure
These steps use VS Code 1.65.2 as an example. The procedure is similar for other IDEs.
-
Start VS Code.
-
Choose View > Command Palette…
-
Enter flutter and choose Flutter: New Project.
-
Enter a project name, such as myapp, and press Enter.
-
After you specify the location for the project, click OK.
The project is ready when the main.dart file appears.
-
Integrate the ApsaraVideo Player SDK for Flutter.
Add the flutter_aliplayer dependency to pubspec.yaml:
dependencies: flutter_aliplayer: ^7.0.0 # The version is the version number of the ApsaraVideo Player SDK for Flutter, for example, 7.0.0. Change the version number as needed. -
Optional: If your business requires support for RTS, add the required dependency. ApsaraVideo Player for Flutter.