测试测试版 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | 商业版 |
发布上次发布 | 2017年3月 |
由Steve Bushell,Jim Whisenant,Tim Rodgers维护。
iOS 8.0及以上。
tvOS 9.0及以上。
Brightcove Player SDK的FairPlay插件为iOS提供了两个安装包,一个静态库框架和一个动态框架。支持iOS 8.0及以上的部署。
FairPlay插件提供了动态框架来支持tvOS 9.0及以上。
**请注意以下iOS/tvOS + FairPlay限制:**
虽然插件包含模拟器架构,但是在模拟器中无法播放FairPlay受保护的内容。
FairPlay流媒体内容不会在AirPlay镜像模式下渲染。有关更多详细信息,请参阅2015年WWDC演讲502:HLS的内容保护。
要手动将Brightcove Player SDK的FairPlay插件添加到您的项目中
BrightcoveFairPlay.framework
添加到您的项目中。BrightcoveFairPlay.framework
bash ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/BrightcoveFairPlay.framework/strip-frameworks.sh
。选中“仅当安装时运行”。这将从构建中删除不需要的架构,这对于提交App Store非常重要。-ObjC
添加到“其他链接器标志”构建设置。Brightcove Player SDK for iOS可以使用几种方式导入到代码中:@import BrightcoveFairPlay;
,#import <BrightcoveFairPlay/BrightcoveFairPlay.h>
或 #import <BrightcoveFairPlay/[specific class].h>
。
Brightcove FairPlay是Apple FairPlay和Brightcove Player SDK for iOS之间的桥梁。以下部分将展示如何设置你的代码以进行基本播放。
当您使用视频云动态分发时,FairPlay应用程序证书的引用会被嵌入在播放服务返回的BCOVVideo对象中。SDK使用此引用在播放您的FairPlay视频时检索应用程序证书。
以下是需要遵循的基本步骤
@property (nonatomic, strong) id<BCOVPlaybackController> playbackController;
-------
// Create a BCOVFPSBrightcoveAuthProxy object using the
// application id and publisher id used to register your
// FairPlay credentials with Brightcove.
BCOVFPSBrightcoveAuthProxy *proxy = [[BCOVFPSBrightcoveAuthProxy alloc] initWithPublisherId:<pub-id>
applicationId:<app-id>];
BCOVPlayerSDKManager *sdkManager = [BCOVPlayerSDKManager sharedManager];
// Brightcove FairPlay adds some category methods to BCOVPlaybackManager.
// If you are using your own FairPlay license server, this is where
// you would pass in your own proxy implementation.
id<BCOVPlaybackController> playbackController = [sdkManager createFairPlayPlaybackControllerWithAuthorizationProxy:proxy];
playbackController.delegate = self;
_playbackController = playbackController;
[self.view addSubview:playbackController.view];
BCOVPlaybackService *playbackService = [[BCOVPlaybackService alloc] initWithAccountId:<account-id>
policyKey:<policy-key>];
[playbackService findVideoWithVideoID:<video-id>
parameters:@{}
completion:^(BCOVVideo *video, NSDictionary *jsonResponse, NSError *error) {
if(video)
{
[self.playbackController setVideos:@[video]];
}
}];
如果您使用的是旧版视频云工作流,在播放视频之前您需要检索FairPlay证书。以下代码显示了基本设置和播放布局
@property (nonatomic, strong) id<BCOVPlaybackController> playbackController;
-------
// Create a BCOVFPSBrightcoveAuthProxy object using the
// application id and publisher id used to register your
// FairPlay credentials with Brightcove.
BCOVFPSBrightcoveAuthProxy *proxy = [[BCOVFPSBrightcoveAuthProxy alloc] initWithPublisherId:<pub-id>
applicationId:<app-id>
BCOVPlayerSDKManager *sdkManager = [BCOVPlayerSDKManager sharedManager];
// Create your FairPlay playback controller using the auth proxy.
id<BCOVPlaybackController> playbackController = [sdkManager createFairPlayPlaybackControllerWithAuthorizationProxy:proxy];
playbackController.delegate = self;
_playbackController = playbackController;
[self.view addSubview:playbackController.view];
// Using the proxy, retrieve the FairPlay application certificate.
// In a production app, you might want to do this as soon as
// the app starts up.
[proxy retrieveApplicationCertificate:^(NSData * _Nullable applicationCertificate, NSError * _Nullable error) {
if (applicationCertificate)
{
// Add the application certificate to the playback controller
[playbackController addFairPlayApplicationCertificate:applicationCertificate
identifier:kBCOVDefaultFairPlayApplicationCertificateIdentifier];
BCOVPlaybackService *playbackService = [[BCOVPlaybackService alloc] initWithAccountId:<account-id>
policyKey:<policy-key>];
[playbackService findVideoWithVideoID:<video-id>
parameters:@{}
completion:^(BCOVVideo *video, NSDictionary *jsonResponse, NSError *error) {
if(video)
{
[playbackController setVideos:@[video]];
}
}];
}
}];
您可以在播放控制器中添加多个FairPlay应用程序证书,但在传统播放中通常只需要一个。如果您使用相同的播放控制器播放来自两个不同账户的视频,您可以添加每个账户的应用程序证书,账户ID作为“identifier”参数。
如果您使用的是创建播放控制器旧行的方法,这些方法将继续工作。新方法创建是为了提供更多灵活性,允许在创建播放控制器之前或之后检索FairPlay应用程序证书,在动态分发的场合,您根本不需要检索或传递应用程序证书。
如果您有任何问题或需要帮助,我们在https://groups.google.com/forum/#!forum/brightcove-native-player-sdks 有Brightcove原生播放器SDK的支持论坛。
播放受FairPlay保护的视频需要关联内容的应用程序证书。
如果您使用视频云动态分发,应用程序证书将按需要下载和使用。证书会被缓存以供重复使用,因此通常每个账户只会下载一次。
如果您使用的是旧版视频云服务,您仍然需要检索一个应用程序证书并将其传递给初始化方法。BCOVFPSBrightcoveAuthProxy类提供了一种便捷的方法,可以从fps.brightcove.com检索该证书。
如果您将您自己的应用程序证书存储在远程位置,您可以使用普通的NSURLSessionDataTask
检索它,作为NSData
对象。一旦收到,您就可以使用-[BCOVPlaybackController addFairPlayApplicationCertificate:identifier:]
将其添加到您的播放控制器中。通常,您会使用kBCOVDefaultFairPlayApplicationCertificateIdentifier
作为标识符。
BCOVFPSBrightcoveAuthProxy旨在与fps.brightcove.com一起使用。如果您需要使用其他FairPlay许可证服务器,您可以实现BCOVFPSAuthorizationProxy协议来处理许可证通信,或者如果您的要求很简单,您可以覆盖一些BCOVFPSAuthorizationProxy属性
/**
* The base url for FairPlay related license requests. The default URL points to
* fps.brightcove.com.
* If set to nil, the default NSURL pointing at fps.brightcove.com will be re-created.
*/
@property (nonatomic, strong, null_resettable) NSURL *fpsBaseURL;
/**
* The key request URL for FairPlay related key requests.
* Normally set to nil, in which case the key request URL
* will be retrieved from the Video Cloud Playback API response.
*/
@property (nonatomic, strong, null_resettable) NSURL *keyRequestURL;
fpsBaseURL属性还用于设置应用程序证书请求的基础URL。证书请求如下
[fpsBaseURL]/application_certificate/[publisherID]/[applicationID]
无论使用Video Cloud还是您自己的服务器,您的BCOVVideo
对象应该包含一个指向某些FairPlay受保护内容的URL的BCOVSource
对象。在FairPlay工作流中,未受保护的视频URL仍可播放。