Build a Sender Application for iOS

Review the following content for information about creating an integrated Chromecast sender application using the Ooyala Mobile SDK for iOS.

Step 1: Set Up Your Environment

Note: Your system must be running iOS version 6 or newer.
  1. Download the Ooyala SDK for iOS from the Ooyala Mobile and Client SDKs Downloads Page.
  2. Download the Cast SDK for iOS.
  3. Download the ChromecastSampleApp from the Ooyala SDK for iOS Sample Apps repository.
  4. Install the iOS Sender API libraries for GoogleCastFramework 2.2.1 or later on your system (see https://developers.google.com/cast/docs/ios_sender).
  5. Review the iOS sender application development details on the Google Developers portal.
The sender includes the following classes:
Class Description
OOCastPlayer The interface between Chromecast device and sender app. It is the object that sends/receives messages. It listens to the action from Ooyala CoreSDK and send the action to the receiver app, and it also listens to the message from the receiver app and transfers it to Ooyala Core SDK.
OOCastManager The interface between customer application/CoreSDK and the OOCastPlayer. It manages the switch between "cast mode" and "local playback mode" and all basic connections between the sender app and the chromecast device.

Step 2: Integrate with the Sender Application

Use the following steps to integrate with the sender application UIViewController with OOOoyalaPlayer (where the UIViewController in the sender application contains a player).
Note: The following code is based on the PlayerViewController class in the ChromecastSampleApp.
  1. Initial Configuration. Open the ChromecastSampleApp project in Xcode.
    • Make sure you have -ObjC linker flag enabled.
    • Link the following libraries as static libraries:
      OoyalaSDK.framework
      OoyalaCastSDK.framework
      GoogleCast.framework
      libz.dylib
  2. Initialize the Cast Manager. Open OOCastManagerFetcher.m and specify your own App ID and NameSpace values:
    App ID The ID you were given when you register the receiver app with which you are trying to connect.
    NameSpace The namespace to identify the protocol of the message being sent for the related receiver app.
    Note: The namespace should not be changed unless you modify the receiver app source code.

Step 3: Configure the Mini Controller (Default) for iOS

Review the following content for information about configuring the mini controller using the Ooyala mobile SDK for iOS.
  1. Open CustomizedMiniControllerView.m. Replace the values of pauseImage and playImage with your own.
  2. Replace ooyala_logo.png with your own image.

Step 4: Customize the iOS Sender Application

The customized sender is custom code that interacts with the Google Sender Cast SDK, Ooyala Mobile SDK and application UX/UI. You can customize the UI/UX of the sender application. The customized sender application loads on the primary device application running on desktop (Chrome) or mobile (iOS/Android) platforms.
  • (Recommended) Uses Google Cast Custom Channel namespace to pass messages.
  • Uses the Cast Message Bus via Custom Channel to facilitate the following:
    • Transmits the embed_code and player_branding_id to the receiver application for launch of the Ooyala Player V4.
    • Transmits basic player functions (stop, play, pause etc.) to the receiver application to control the Ooyala Player V4.
    • Via Custom Channel Listener, receives Ooyala related player errors based on player message bus events and translates them to application-friendly user messages. An example use case is if the Ooyala Device Management feature is used. The /last_Result messages are published in the player message bus and passed back to the sender; based on these results, the appropriate message is passed back to the application.
  1. Customized Mini Controller. Open CustomizedMiniControllerView.m and adjust the values according to your application needs. The remaining steps apply to the customized mini controller.
  2. Take the castManager as a property in your class.
  3. Instantiate play/pause the casting video through [self.castManager.castPlayer play]/[self.castManager.castPlayer pause].
  4. Update the play/pause button image.
  5. Manage cast mode video view (The UIView fills in the blank video view in OOOoyalaPlayer when casting video).
  6. Set the castModeVideoView in castManager as shown in the following code sample: [self.castManager setCastModeVideoView:videoView]; This view is displayed in the videoView of OOOoyalaPlayer when casting the video.

Debugging a Sender Application

Use the function printDebugMessage to dynamically debug the Chrome developer tools console output about sender commands and Ooyala Player events. Media status objects can be monitored on the receiver debug console with the MediaManager.customizedStatusCallback function. You can customize which events are reported to the logs and select to see errors from the Chromecast and/or Ooyala namespace.

Open a browser window and point it to the IP address of the Chromecast unit (port 9222). For more information on how to debug from this point, go to Google’s Chromecast Developer Guide topic on debugging and Google's topic on handling Cast Media error messages.

OOCastManager Notifications

Notification Description
OOCastManagerFailToConnectNotification This notification is sent when a OOCastManager fails to connect to a chromecast device.
OOCastDeviceLostNotification This notification is sent when a chromecast device lost. It does not mean the connection to the device was lost.
OOCastManagerDidDisconnectNotification This notification is sent when a castManager disconnects from chromecast device.
OOCastEnterCastModeNotification This notification is sent when the app enters cast mode.
OOCastExitCastModeNotification This notification is sent when the app exits cast mode.
OOCastMiniControllerClickedNotification This notification is sent when a mini controller event is activated.

Was this article helpful?