Chromecast integration
Table of contents
This section describes how to integrate the Flowplayer SDK with the Google Cast SDK, to be able to show and control media on a Google Cast device. The instructions assume you have installed the Flowplayer SDK and its dependencies in your app.
Download the SDK
You can download the SDK in one of the following 2 ways.
CocoaPods
Add FlowplayerChromecast
together with its dependencies in your Podfile
:
pod 'Flowplayer', '~> 3.0.3' # required
pod 'FlowplayerChromecast', '~> 3.0.3'
Execute pod install
and you're ready to go.
Make sure to use Google Cast
iOS SDK version 4.7.0
or above
Make sure to use Flowplayer
version 3.0.3
or above
Manually
Download the XC framework of Flowplayer Chromecast iOS SDK from here.
Only for Apple Silicon and CocoaPods
If you have arm64
excluded as a valid architecture for Simulators, please add the following code at the bottom of your Podfile file so that Protobuf the dependency of 'Google Cast' can compile.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Disable arm64 arch for Protobuf :(
# As of writing this most dep. are x86_64 compiled and not arm64. 03.02.2022
if target.name == "Protobuf"
if config.name == "Debug"
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
end
end
Add Google Cast to your project
Follow the instructions for how to add the Google Cast SDK to your project (Develop iOS Sender App: Setup). This involves adding the Cast SDK—either manually or via 3rd party dependency managers like cocoapods—and all its dependencies. Also, don't forget to add the needed capabilities in your Xcode project.
How to use a custom Google Cast receiver app
If you have your own Cast receiver app, you can set the app id in your iOS app's Info.plist, using the key FlowplayerCastReceiverAppId
. If not set, the Flowplayer SDK will use Flowplayer's default Cast receiver app.
Starting the manager
Early on in your app's startup process, you need to start the FPCastManager
. The Flowplayer cast manager will in turn start the Google Cast context provided by the Google Cast SDK.
Your app delegate's application:didFinishLaunchingWithOptions:
is a good place to start the cast manager:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Start the cast manager.
FPCastManager.shared.start()
return true
}
Add cast button
Please follow the instructions on google cast to add an cast button here.