|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|
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.
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.|
In this demo, you can debug the project on a simulator.Find the target simulator and debug the project on it.
If you do not store the specified profile on your computer, Xcode reports an error, as shown in the following figure.You 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.
This solution offers the following features: video playback, video classification, VIP membership, video advertisement, image advertisement, marquee, watermark, progress bar marker, and video download.
When the LongVideo solution is used, you need to integrate the ApsaraVideo Player SDK to play videos.
To integrate the ApsaraVideo Player SDK, add the pod ‘AliPlayerSDK_iOS’ statement to the Podfile and run the pod install command.
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 the basic code and public components that the project depends on, and the code of the LongVideo solution to your project.
- Basic code and public components that the project depends onCopy the files highlighted in red to your project, as shown in the following figure.
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.
- Add the following reference to a
.pchfile in your project:
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.
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', '~> 18.104.22.168'
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.