Click SDK download 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.
|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|
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.
|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.|
Method 1. Set up a debugging environment for simulators
In this demo, you can debug the project on a simulator.Find the target simulator and debug the project on it.
Method 2. Set up a debugging environment for physical devices
LongVideo solution integration
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.
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.
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.
- Code of the LongVideo solutionCopy the files highlighted in red to your project, as shown in the following figure.
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
.pchfile in your project:
#import "AlivcImage.h" #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.
Build Settingsto configure the PCH file, as shown in the following figure.
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.
Add the following reference to a Podfile:
pod 'MJRefresh', '~> 220.127.116.11' pod 'LBXScan/LBXNative','~> 2.3' pod 'LBXScan/UI','~> 2.3' pod 'MBProgressHUD', '~> 1.1.0' pod 'SDWebImage', '~> 4.0.0' pod 'AFNetworking', '~> 3.0' pod 'FMDB',:git => 'https://github.com/ccgus/fmdb.git',:tag => '2.7' pod 'JSONModel','~> 1.7.0' pod 'MRDLNA',:git => 'https://github.com/MQL9011/MRDLNA.git' 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.