Cast Ads Support for Sender Apps

Ads Overview

The Cast SDK frameworks for Android and iOS enable your app to present the following user experience for advertisements:

  • Draw ad breaks on the seek bar in the expanded controller (whether or not an ad is playing).
  • During an ad, alter the UI for the following controllers:
Expanded controller
  • Disable all buttons except play/pause
  • Disable the seek bar
  • Show ad text centered below the poster
  • Replace the ad background poster with the video poster
  • Skippable Ad: Display countdown to when ad is skippable (Android only)
  • Skippable Ad: "Skip Ad" button appears when ad can be skipped (Android only)
Mini controller
  • Disable all buttons except play/pause
Notification controls
  • Disable all buttons except play/pause

Either the sender or the receiver can provide the ads metadata.

If your receiver app is responsible for providing the ads metadata to your sender app, it must send the metadata as custom data in the media status updates. Your sender app needs to parse the ads metadata and then configure the media status object with the ads data. The Cast framework widgets use the ads data to update their UI’s to the user when ads are playing.

If your sender app provides the metadata, it must put the list of AdBreakInfo and the list of AdBreakClipInfo in the MediaInfo that the RemoteMediaPlayer will load.

For ads, your custom receiver app needs to provide the following information in the custom JSON data:

  • A boolean flag indicating whether your receiver is currently playing an ad.
  • A list of playback positions at which the ads occur.

Once your sender app has configured the media status instance with the ads data, the Cast framework will present the UI changes listed above.

Android: Set up sender app for ads

Follow these steps to set up the controller UX widgets to adjust appropriately for ads:

  1. Your sender app's RemoteMediaClient instance receives a media status message from your receiver.

  2. Your sender app needs to implement and set a ParseAdsInfoCallback to the RemoteMediaClient. The callback will be invoked before RemoteMediaClient propagates the MediaStatus to its listeners. The implementation should parse the MediaStatus and custom JSON data to return ads metadata:

  3. After returning from the invocation of ParseAdsInfoCallback, RemoteMediaClient propagates the updated MediaStatus as usual to its listeners.

  4. The Cast framework widgets use the ads data to update their UI when playing ads.

iOS: Set up sender app for ads

Follow these steps to set up the controller UX widgets to adjust appropriately for ads:

  1. The GCKRemoteMediaClient instance receives a media status message from your receiver.

  2. The GCKRemoteMediaClient instance allows your sender app to modify the GCKMediaStatus object by implementing a GCKRemoteMediaClientAdInfoParserDelegate. Note that if custom data is present, it will be made available to the client as part of the GCKMediaStatus customData property. In this step, your sender app’s delegate is responsible for parsing the custom data, and if necessary set the GCKMediaStatus and GCKMediaInformation in this way:

  3. After the client has updated the GCKMediaStatus object, the GCKRemoteMediaClient instance propagates the updated object as usual to its listeners.

  4. The Cast framework widgets use the ads data to update their UI when playing ads.