Build a Sender Application for Android

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

Step 1: Set Up Your Environment

  1. Download the Ooyala SDK for Android from the Ooyala Mobile and Client SDKs Download Page.
  2. Download the Cast SDK for Android.
  3. Download the Cast Companion Library.
  4. Download the ChromecastSampleApp from the Ooyala SDK for Android Sample Apps repository.
  5. Review the Android sender application development details on the Google Developers portal Android App Development.

Step 2: Integrate with the Sender Application

Use the following steps to integrate with the sender application without the OoyalaPlayer object (where the sender application does not contain a player, for example, when you open the app it only contains a list of videos you can play with no player embed). The list activity and Chromecast player activities show videos available for casting when the app is running. The player activity contains the Ooyala player that renders the videos.

These steps are written to extend the basic Ooyala Sample App.

Note: The following steps assume that you have knowledge of basic integration steps for the Ooyala Core SDK and an existing OoyalaPlayer setup. For details about creating the player, see the Ooyala Support site topic Creating a Basic Android App.
  1. Initial configuration. Open the ChromecastSampleApp in Android Studio.
  2. Configure the namespace and app ID. Open SampleApplication.java and change the value of NAMESPACE and APP_ID. This is shown in the following code sample:
    public class SampleApplication extends Application {
    ...
    private final String NAMESPACE = "urn:x-cast:ooyala";
    private final String APP_ID = "4172C76F";
    ...
    Note: The APP_ID and NAMESPACE support the default receiver. For custom receivers adjust the code accordingly.
  3. Initialize CastManager with the following credentials:
    APP_ID The ID provided when the app is registered with the receiver app.
    NAMESPACE The namespace to identify the protocol of the message being sent for the related receiver app. namespaces is array of namespace. In most cases only one namespace is required. Based on current version of SDK, only the first namespace in the array is taken.
    Note: The namespace should not be changed unless you modify the receiver app source code.
    This step is shown in the following code sample:
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
      ...
       castManager = CastManager.initialize(getApplicationContext(), APP_ID, NAMESPACE);
       castManager.setStopOnDisconnect(true);
      ...
    }
    Note: CastManager is a static variable. Keep this object throughout the app life cycle.

Step 3: Configure the Chromecast Mini Controller for Android

Configure the mini controller using the Ooyala mobile SDK for Android. The mini controller controls appear when the user navigates away from the main player controls. These controls provide instant access to, and a visible reminder for,the currently casting video. The Android SDK mini controller implementation includes the following controllers:
Controller Description
Activity mini controller (Required by Google) When the user navigates out of the main player activity (the activity contains OoyalaPlayer), the current activity should have a mini controller embed somewhere so that the user can still have the control of casting video.
Notification mini controller (Required by Google) When and only when the app is running in background, there will be a mini controller notification bar.
Lock screen mini controller (Required for KitKat only) When the device is in lock screen there could be a mini controller available for user to control the current casting video without unlocking the screen.
Cast Menu mini controller (Required by Google) During casting, there should be a mini controller inside cast menu.
The Android mini controller is provided by the CastCompanionLibrary. To customize the mini controller, modify mini_controller.xml.
Note: To use OoyalaCastSDK to manage the mini controller navigation include the singleTop launchMode for all activities and set parentActivityName all activities in the Manifest. Refer to the ChromecastSampleApp Manifest for more details.

Step 4: Customize the Android 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 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.
The CastCompanionLibrary contains all the assets. You can customize these assets for your application. For details see https://github.com/googlecast/CastCompanionLibrary-android/blob/master/CastCompanionLibrary.pdf.

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?