Using Player Enhancements for Live SSAI with the Native SDKs

In this topic, you will learn how to play a live stream with the Brightcove Native SDKs that includes server-side ads and utilizes Player Enhancements for Live SSAI for an improved user experience.

Introduction

Brightcove's Player Enhancements for Live SSAI allows you to improve the ad breaks in live streams with ad counts, ad countdown timers, click through ads and companion ads. These live streams can be played using the Brightcove Native SDKs.

Client-side ad components
Client-side ad components

Since TVs do not support a web browser, companion and click-through ads are not available on connected TVs.

If you are new to this feature, see the following:

Steps

To play live streams with an enhanced player using the Brightcove Native SDKs, follow these steps:

  1. Follow the workflow in the Implementing Player Enhancements for Live SSAI document, up through creating your playback token.
  2. Build your app:

  3. Continue with the workflow in the the Implementing Player Enhancements for Live SSAI document.

Android implementation

You will need the following values to build your app using the Native SDK for Android:

  • Playback token
  • Account Id
  • Video Id
  • Policy Key

To get your Policy Key, review the Policy Keys document.

Follow these steps to build your app:

  1. Use the Basic SSAI Sample App as a starting point for your code.
  2. In the res/values/strings.xml file, replace the following with your own values:
    • Account Id
    • Video Id
    • Policy Key
  3. In the MainActivity.java file, replace the ad_config_id value with your playback token.

    private final String AD_CONFIG_ID_QUERY_PARAM_VALUE = "your playback token";
  4. The ad_config_id with your playback token value is added to the HTTP request as a query parameter.

    HttpRequestConfig httpRequestConfig = new HttpRequestConfig.Builder()
      .addQueryParameter(AD_CONFIG_ID_QUERY_PARAM_KEY, AD_CONFIG_ID_QUERY_PARAM_VALUE)
      .build();
  5. Make the catalog call to the Playback API with your live stream video id and the updated HTTP request.

    catalog.findVideoByID(getString(R.string.video_id), httpRequestConfig, new VideoListener() {
         @Override
         public void onVideo(Video video) {
             plugin.processVideo(video);
         }
     });
  6. Your player is ready to play your live stream.

iOS implementation

You will need the following values to build your app using the Native SDK for iOS:

  • Playback token
  • Account Id
  • Video Id
  • Policy Key

To get your Policy Key, review the Policy Keys document.

Follow these steps to build your app:

  1. Use the Basic SSAI Player sample as a starting point for your code.
  2. In the ViewController.swift file, replace the following with your own values:
    • Account Id
    • Video Id
    • Policy Key
  3. Replace the AdConfigId value with your playback token.

    static let AdConfigId = "your playback token"
  4. The AdConfigId with your playback token value is added as a query parameter.

    let queryParameters = [kBCOVPlaybackServiceParamaterKeyAdConfigId: Constants.AdConfigId]
  5. Make the catalog call to the Playback API with your live stream video id and the query parameter.

    playbackService.findVideo(withVideoID: Constants.VideoId, parameters: queryParameters)
      { [weak self] (video: BCOVVideo?, jsonResponse: [AnyHashable: Any]?, error: Error?) -> Void in
      guard let _video = video else {
        print("ViewController Debug - Error retrieving video: \(error?.localizedDescription ?? "unknown error")")
        return
      }
      self?.playbackController?.setVideos([_video] as NSFastEnumeration)
    }
  6. Your player is ready to play your live stream.