CPEExperience
根据电影实验室的各种规格和标准,为iOS构建的增强型“额外内容”体验。此参考库旨在允许实施者加速其跨平台额外iOS实现。
安装
CocoaPods
CocoaPods是Cocoa项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用CocoaPods将CPEExperience集成到您的Xcode项目中,请在您的Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'CPEExperience', '~> 4.1'
end
然后,运行以下命令:
$ pod install
设置
通知
将以下通知添加到CPEExperience库中,以显示AppDelegate方法调用
func applicationWillEnterForeground(_ application: UIApplication) {
NotificationCenter.default.post(name: .applicationWillEnterForeground, object: nil)
}
func applicationWillResignActive(_ application: UIApplication) {
NotificationCenter.default.post(name: .applicationWillResignActive, object: nil)
}
代理
在任何基础应用程序的类中实现ExperienceDelegate接口并添加所需的方法
// Connection status
func connectionStatusChanged(status: ConnectionStatus)
// Experience status
func experienceWillOpen()
func experienceWillClose()
func experienceWillEnterDebugMode()
// Preview mode callbacks
func previewModeShouldLaunchBuy()
// Video Player callbacks
func interstitialShouldPlayMultipleTimes() -> Bool
func playbackAsset(withURL url: URL, title: String?, imageURL: URL?, forMode mode: VideoPlayerMode, completion: @escaping (PlaybackAsset) -> Void)
func didFinishPlayingAsset(_ playbackAsset: PlaybackAsset, mode: VideoPlayerMode)
// Sharing callbacks
func urlForSharedContent(id: String, type: SharedContentType, completion: @escaping (_ url: URL?) -> Void)
// Talent callbacks
func didTapFilmography(forTitle title: String, fromViewController viewController: UIViewController)
// Analytics
func logAnalyticsEvent(_ event: AnalyticsEvent, action: AnalyticsAction, itemId: String?, itemName: String?)
请参考示例项目中的InputViewController
类了解此实现的示例。
Chromecast
如果你将支持从视频播放器播放Google Chromecast,请将以下初始化调用添加到你的基础应用程序中,最好是放在AppDelegate的方法中,用你的Chromecast应用程序ID替换参数
CastManager.sharedInstance.start(withReceiverAppID: "x")
示例项目使用
在Xcode中打开Example/CPEExperienceExampleWorkspace.xcworkspace
以构建和运行示例项目,该项目中包含参考所需的调用和代理挂钩,以将跨平台附加功能体验集成到您的视频平台中。