All Products
Search
Document Center

LongVideo solution integration for iOS

Last Updated: Oct 15, 2019

Environment requirements

Name Requirement
Xcode Xcode 9.0 or later
Simulator Built-in system: iOS 9 and later
CPU architecture support ARM64, ARMv7, and ARMv7s
Operating system iOS 9.0 or later

Demo download

Click here to go to the download page. Then, find and download the LongVideo source code package in the Download link column of the LongVideo source code table.

Open a project

The directory structure of the LongVideo source code package is as follows. Double-click the AliyunVideoClient_Entrance.xcworkspace file to open the project.Project entry file

Directory structure

Directory structure

Name Description
AlivcPlayPublic The public playback component.
AlivcLongVideo The business code of LongVideo.
AlivcVideoPlay The code of video playback.
AlivcAbstraction The business abstractions of the project.
AlivcFramework This directory has no use because the player SDK is integrated by using CocoaPods.
Assets.xcassets The public images.
AppSupportFiles The files that are automatically created during project initialization.
Categories The categories, including the categories of all classes.
Config The configuration, including the macro definition, global configuration, global constant, and color configuration files.
Home The code of the project homepage.
Frameworks The system frameworks, including imported system frameworks.
Helpers The helper classes, which package and implement operation classes such as the network, database, archiving, positioning, and string operation classes.
Resources The global resources, including .plist, .image, .html, .bundle, and Localizable.strings files.
Utilites The utility classes, including some classes that can be called by class methods instead of object methods, and some functional abstract classes.
Vendors The third-party libraries. Some libraries need to be modified or do not support third-party frameworks imported by CocoaPods.
Pods The third-party libraries managed by CocoaPods.

Project compilation

Method 1. Set up a debugging environment for simulators

In this demo, you can debug the project on a simulator.SimulatorFind the target simulator and debug the project on it.

Method 2. Set up a debugging environment for physical devices

If you do not store the specified profile on your computer, Xcode reports an error, as shown in the following figure.Debugging environment for physical devicesYou can add the profile or log on to a developer account to set up an environment for physical devices. To log on to a developer account, you need to create an Apple ID.Click here to create an Apple ID.After you deploy the runtime environment on a physical device, press command+R on the keyboard or click the triangle icon in the upper-left corner of Xcode to run the project.

LongVideo solution integration

Overview

This solution offers the following features: video playback, video classification, VIP membership, video advertisement, image advertisement, marquee, watermark, progress bar marker, and video download.

Integrate the player SDK

When the LongVideo solution is used, you need to integrate the ApsaraVideo Player SDK to play videos.

Method 1. Integrate the ApsaraVideo Player SDK by using CocoaPods

To integrate the ApsaraVideo Player SDK, add the pod ‘AliPlayerSDK_iOS’ statement to the Podfile and run the pod install command.

Method 2. Integrate the ApsaraVideo Player SDK by copying code files

To integrate the ApsaraVideo Player SDK, you need to copy the player SDK files to your project and then add them in the Embedded Binaries section, as shown in the following figure.SDK integration

Copy business code files

Copy the basic code and public components that the project depends on, and the code of the LongVideo solution to your project.

  1. Basic code and public components that the project depends onCopy the files highlighted in red to your project, as shown in the following figure.

Copy business code files

Code files from top to bottom are as follows:

AlivcPlayListRequest: the playback component.

Categories: the categories required by the project.

Config: the configuration files of the project.

Helpers: the helper classes required by the project.

Utilites: the utility classes required by the project.

  1. Code of the LongVideo solutionCopy the files highlighted in red to your project, as shown in the following figure.

Code of the LongVideo solution

Code files from top to bottom are as follows:

AlivcPlayPublic: the public playback code.

AlivcLongVideo: the code for the LongVideo solution.

AlivcVideoPlay: the code for video playback.

Configure the PCH file

  • Add the following reference to a .pch file in your project:
    1. #import "AlivcImage.h"
    2. #import "AlivcMacro.h"

If your project does not contain a .pch file, you can copy the PrefixHeader.pch file from the demo. Keep the preceding reference in the .pch file.

  • Choose TARGETS > Build Settings to configure the PCH file, as shown in the following figure.WX20181020-002351@2x.png

Prefix Header: Enter the directory of the PrefixHeader.pch file in your project, for example, $(SRCROOT)/Your own directory/PrefixHeader.pch.

Set up the project environment

Add the App Transport Security Settings option. Add its child attribute Allow Arbitrary Loads and set its value to Yes to enable HTTP requests.

Integrate CocoaPods

Add the following reference to a Podfile:

  1. pod 'MJRefresh', '~> 3.1.15.7'
  2. pod 'LBXScan/LBXNative','~> 2.3'
  3. pod 'LBXScan/UI','~> 2.3'
  4. pod 'MBProgressHUD', '~> 1.1.0'
  5. pod 'SDWebImage', '~> 4.0.0'
  6. pod 'AFNetworking', '~> 3.0'
  7. pod 'FMDB',:git => 'https://github.com/ccgus/fmdb.git',:tag => '2.7'
  8. pod 'JSONModel','~> 1.7.0'
  9. pod 'MRDLNA',:git => 'https://github.com/MQL9011/MRDLNA.git'
  10. pod 'AliPlayerSDK_iOS',:git => 'https://github.com/aliyunvideo/AliPlayerSDK.git',:tag => '4.7.0'

On a physical device where your project is run, run the cd command to go to the directory of the Podfile, and then run the pod install command.