aliplayersdk_ios

Introduction

AliPlayerSDK for iOS is a powerful media player SDK developed by Alibaba Group. It provides various features and functionalities to integrate video playback in iOS applications.

Features

  • Supports a wide range of video formats including MP4, M3U8, FLV, and more.
  • Efficient streaming capabilities for video-on-demand (VOD) and live streaming scenarios.
  • Flexible customization options for player UI, including control bar, full-screen mode, and playback controls.
  • Advanced playback controls such as play, pause, seek, and playback rate adjustment.
  • Detailed playback information and events for monitoring and analytics.
  • Supports multiple audio tracks and subtitle selection.
  • Adaptive bitrate streaming for smooth playback across different network conditions.
  • Seamless integration with media platforms like Aliyun VOD and Alibaba Cloud Media Center.

System Requirements

  • iOS 9.0 or later
  • Xcode 11 or later
  • Swift 5 or later (Objective-C support also available)

Installation

Step 1: Add Dependency

To get started, you need to add AliPlayerSDK as a dependency in your project. You can do this via Cocoapods, or manually by downloading and adding the framework files.

Cocoapods

Add the following line to your Podfile:

pod 'AliPlayerSDK'

Then, run pod install in the terminal to install the SDK.

Manual Installation

To manually install the SDK, follow these steps:

  1. Download the AliPlayerSDK framework from the official website.
  2. Unzip the downloaded file.
  3. In Xcode, select your project target.
  4. Go to the “General” tab.
  5. Drag and drop the AliPlayerSDK.framework to the “Frameworks, Libraries, and Embedded Content” section.
  6. Make sure to select “Copy items if needed” and “Create groups” options.
  7. Verify that AliPlayerSDK.framework is added to “Frameworks, Libraries, and Embedded Content”.

Step 2: Import SDK

In your Swift or Objective-C file, import the AliPlayerSDK module using the following line:

import AliPlayerSDK

Usage

Initializing the Player

To initialize the AliPlayer object, you can use the following code:


let player = AliPlayer()

Setting the Media URL

After initializing the player, you can set the media URL you want to play:


player.setUrl("https://example.com/video.mp4")

Configuring the Player

Various player settings can be configured through the AliPlayer object. Here is an example:


let config = player.getConfig()
config.scalingMode = .aspectFill
player.setConfig(config)

Starting Playback

To start the playback, use the following code:


player.play()

Additional Functionality

AliPlayerSDK provides a plethora of additional functionality, including:

  • Playback controls: pause, resume, seek
  • Volume and brightness control
  • Playback rate adjustment
  • Event callbacks for monitoring playback state and progress
  • Subtitle and audio track selection
  • Full-screen mode

Conclusion

Congratulations! You have successfully integrated AliPlayerSDK for iOS into your project. You can now leverage its powerful features to enhance your video playback experience.