Brightcove Native Player for iOS Reference
Google Cast Plugin for Brightcove Player SDK for iOS, version 7.0.0.9
Installation
The Google Cast Plugin for Brightcove Player SDK provides a static library framework for installation.
The Google Cast plugin supports version 4.8.1 of the Google Cast SDK for iOS. The Google Cast release notes can be found here.
CocoaPods
You can use CocoaPods to add the Google Cast Plugin for Brightcove Player SDK to your project. You can find the latest Brightcove-Player-GoogleCast podspecs here. The pod will incorporate the correct version of GoogleCast automatically.
CocoaPod Podfile example:
source 'https://github.com/CocoaPods/Specs'
source 'https://github.com/brightcove/BrightcoveSpecs.git'
platform :ios, '14.0'
use_frameworks!
target 'ExampleApp' do
pod 'Brightcove-Player-GoogleCast'
end
When updating your installation, it’s a good idea to refresh the local copy of your BrightcoveSpecs repository to ensure you have the latest podspecs locally, just like you would update your CococaPods master repository. Use pod repo update
to do so.
Manual
To add the Google Cast Plugin for Brightcove Player SDK to your project manually:
- Follow the Google Cast SDK Manual Setup guide.
- Follow the Brightcove Player SDK Manual Installation guide.
- Download the Google Cast Plugin for Brightcove Player SDK framework.
- On the “General” tab of your application target, add
BrightcoveGoogleCast.framework
orBrightcoveGoogleCast.xcframework
from the Google Cast Plugin for Brightcove Player SDK download to the list of Frameworks, Libraries, Embedded Content. - On the “Build Settings” tab of your application target, ensure that the “Framework Search Paths” include the paths to the frameworks. This should have been done automatically unless the framework is stored under a different root directory than your project.
- (Universal Framework only) On the “Build Phases” tab, add a “Run Script” phase with the command
bash ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/BrightcoveGoogleCast.framework/strip-frameworks.sh
. Check “Run script only when installing”. This will remove unneeded architectures from the build, which is important for App Store submission. - (Apple Silicon with Universal Framework only) On the “Build Settings” tab of your application target:
- Ensure that
arm64
has been added to your “Excluded Architectures” build setting forAny iOS Simulator SDK
.
- Ensure that
Swift Package Manager
To add the Google Cast Plugin for Brightcove Player SDK to your project with Swift Package Manager:
- First follow the steps to add the Core XCFramework with Swift Package Mananger.
- Add the Google Cast package to Swift Package Manager using
https://github.com/brightcove/brightcove-player-sdk-ios-googlecast.git
. - Follow the Google Cast SDK Manual Setup guide.
Imports
The Google Cast Plugin for Brightcove Player SDK can be imported using:
import BrightcoveGoogleCast
Before You Begin
Before attempting to utilize this plugin you should already be familiar with the following:
- Register your application. This will walk you through creating your reciever application and grant you an application ID. Starting out you can use the demo application ID ‘4F8B3483’.
- Setup for Developing with the Cast Application Framework (CAF) for iOS . This will walk you through setting up the necessary entitlements for your app.
- Initialze the Cast Context. This will walk you through initializing the Cast Context with your receiver application ID.
- Add Mini Controllers. This will walk you through how to take advantage of the Google Cast SDK’s mini media controls.
Quick Start
The BrightcoveGoogleCast plugin is a bridge between Google Cast iOS SDK and the Brightcove Player SDK for iOS.
This snippet shows its basic usage.
[1] googleCastManager = BCOVGoogleCastManager()
[2] playbackController = BCOVPlayerSDKManager.sharedManager().createPlaybackController()
[3] playbackController?.add(googleCastManager)
Breaking the code down into steps:
- Create a reference to the BCOVGoogleCastManager singleton.
- Create an instance of BCOVPlaybackController to use.
- Add your BCOVGoogleCastManager reference as a session consumer to your BCOVPlaybackController instance.
Brightcove CAF Receiver
The application ID for the Brightcove CAF Receiver is 341387A3
and is assigned to the constant kBCOVCAFReceiverApplicationID
. You can verify the application ID by checking the CAF Receiver config.json.
If you are using the Brightcove CAF Receiver you’ll need to initialize these variables like this:
[1] let receiverAppConfig = BCOVReceiverAppConfig()
receiverAppConfig.accountId = "<account-id>"
receiverAppConfig.policyKey = "<policy-key>"
[2] googleCastManager = BCOVGoogleCastManager(forBrightcoveReceiverApp: receiverAppConfig)
The following properties are also available to set on BCOVReceiverAppConfig
as needed:
- splashScreen (for customizing the splash screen image)
- playerUrl (for using a customized player)
- authToken (for use with PAS/EPA)
- watermarkingToken (for use with Forensic Watermaking)
- adConfigId (for use with SSAI)
- userId (for use with analytics tracking)
- applicationId (for use with analytics tracking)
NOTE: When using the Brightcove Cast Receiver app with the Brightcove Native SDKs, you must send the catalogParams
object via the customData
interface. A static URL is not supported. If you are correctly utilizing the BCOVReceiverAppConfig
class this is handled for you.
Generic Stream Concurrency
Generic Stream Concurrency is supported when using the Brightcove CAF Receiver. You must create a web player that has stream concurrency enabled.
At this time, there is no dedicated UI for this feature in Studio, so the JSON editor must be used. The configuration will look something like this:
"video_cloud": {
"stream_concurrency": true,
"policy_key": "BCpk..."
},
"player": {
"template": {
"name": "single-video-template",
"version": "6.63.1"
}
},
Once you have configured your player you can specify your GSC enabled player using the playerUrl
property on BCOVReceiverAppConfig
:
receiverAppConfig.playerUrl = "https://players.brightcove.net/.../index.min.js"
The following claims are required:
* climit
: The concurrency limit claim indicates how many watchers or streams can play at the same time.
* uid
: The viewer identifier is used to correlate multiple sessions to enforce Stream Concurrency
* sid
: Correlator identifier defines the streaming locations for a viewer.
For additional information please see the Implementation section of our Generic Stream Concurrency guide.
You can then set the authToken
property on BCOVReceiverAppConfig
with your JWT:
receiverAppConfig.authToken = <jwt>
Delegate Methods
BCOVGoogleCastManagerDelegate has delegate methods you can use to be notified when major cast-related events have occurred or are about to occur, for example
func switched(toLocalPlayback lastKnownStreamPosition: TimeInterval, withError error: Error?)
func switchedToRemotePlayback()
func currentCastedVideoDidComplete()
func castedVideoFailedToPlay()
func suitableSourceNotFound()
func willBuild(_ builder: GCKMediaInformationBuilder)
func willSend(_ mediaLoadOptions: GCKMediaLoadOptions)
For a complete list with descriptions, refer to the BCOVGoogeCastManagerDelegate Protocol Reference.
To take advantage of these events, set a delegate on the BCOVGoogleCastManager singleton.
googleCastManager.delegate = self
Source Selection
The BCOVGoogleCastManager will attempt to find a suitable source to use. It will look for sources in this order:
- HTTPS HLS v3
- HTTPS DASH
- HTTPS MP4
- HTTP HLS v3
- HTTP DASH
- HTTP MP4
If none of these are found, the delegate method suitableSourceNotFound
will be called.
Your Video Cloud account will need to be set up to support HLS v3, ensure that DASH is enabled or have an MP4 source available for each video.
Customizations
There are two properties, in addition to the delegate property, that you can set on the BCOVGoogleCastManager class. These are:
fallbackPosterImage: GCKImage
: The GCKImage that will be used when there is no poster image available for a video.posterImageSize: CGSize
: The height and width that you want to use for the GCKImage object image that is created. Defaults to 480h x 720w.
Known Issues / Limitations
When using a default, unmodified receiver (including the demo receiver) the following limitations apply:
- DRM is not supported.
- Multiple Audio Tracks are not supported.
- Client-side and Server-side Advertising are not supported.
- Live and Live DVR streams are not supported.
When using the Brightcove CAF receiver the following limitations apply:
- Client-side Advertising is not supported.
Support
If you have questions, need help or want to provide feedback, please use the Support Portal or contact your Account Manager. To receive notification of new SDK software releases, subscribe to the Brightcove Native Player SDKs Google Group.