Cross-Device Resume with the Native SDKs

In this topic, you will learn how to use Cross-Device Resume with the Brightcove Native SDKs.

Overview

Cross-Device Resume allows viewers to start watching a video on one device, and at a later time, continue watching the video where they left off on the same or a different device.

Let's say that someone starts watching a video on their mobile device. Later, they can continue watching the same video with a player on their web browser. Playback will continue where they left off, so they won't miss a thing.

If you are not familiar with this feature, see the Overview: Cross-Device Resume document.

Requirements

The following requirements are needed for Cross-Device Resume with the Brightcove Native SDKs:

Brightcove Native SDK version

  • Native SDK for Android 6.13.1+
  • Native SDK for iOS 6.0.1+, for Pulse 6.7.5+, for SSAI 6.7.7+

Device OS version

  • Android 6.0+
  • iOS 11.0+

Setup

This feature is available to anyone with a Brightcove Video Cloud account.

To get started, do the following

  • Contact your account manager to enable your account for Cross-Device Resume
  • Make sure the videos you are using are ingested for Dynamic Delivery

Implementing Cross-Device Resume

To implement Cross-Device Resume, follow these steps:

  1. Set the user identifier for Brightcove analytics

    Even though viewer data is sent to Brightcove analytics automatically, you need to set the user identifier.

    You can use an authentication gateway or some identity management solution to keep track of viewers. Use this viewer ID as the user identifier to pass to Brightcove analytics.

  2. Get the viewer playback position from the Cross-Device Resume (XDR) API

  3. Resume playback

Android Implementation

For the Native SDK for Android, follow these steps:

  1. Set the user identifier for Brightcove analytics.

    HashMap<String, String> baseParams = new HashMap<>();
    baseParams.put(Analytics.Fields.USER, "viewer id");
    baseParams.put(Analytics.Fields.APPLICATION_ID, "application id");
    
    HashMap<String, Object> eventParams = new HashMap<>();
    eventParams.put(Analytics.Fields.BASE_PARAMS, baseParams);
    eventEmitter.emit(EventType.ADD_ANALYTICS_BASE_PARAMS, eventParams);
    
  2. Get the viewer playback position from the Cross-Device Resume (XDR) API.

    For details, see the following:

  3. Resume playback.

    Once you get the viewer playback position from the XDR API, you can resume playback from that point. Set the playhead position using the brightcoveVideoView.seekTo() method.

    final VideoPlaybackController playbackController = brightcoveVideoView.getPlaybackController();
    eventEmitter.on(EventType.VIDEO_DURATION_CHANGED, new EventListener() {
      @Override
      public void processEvent(final Event event) {
        playbackController.setAdsDisabled(true);
        brightcoveVideoView.seekTo(<viewer playhead position>);
      }
    });
    
    eventEmitter.on(EventType.DID_SEEK_TO, new EventListener() {
      @Override
      public void processEvent(final Event event) {
        playbackController.setAdsDisabled(false);
      }
    });
    

iOS Implementation

For the Native SDK for iOS, follow these steps:

  1. Set the user identifier for Brightcove analytics.

    @try
      {
        [BCOVGlobalConfiguration.sharedConfig setValue:@{
          @"privateUser": self.viewer id,
          @"privateApplication": @"application id"
        }
        forKey:@"privateSessionAnalytics"];
      }
      @catch (NSException *e)
      {
        NSLog(@"%@", e.description);
      }
    
  2. Get the viewer playback position from the Cross-Device Resume (XDR) API.

    For details, see the following:

  3. Resume playback.

    Once you get the viewer playback position from the XDR API, you can resume playback from that point. Set the playhead position using the following method:

    -[BCOVPlaybackController seekWithoutAds:(CMTime)seekToTime completionHandler:(void (^)(BOOL finished))completion]
    

    This allows you to resume playback at a specific time without forcing the viewer to watch ads scheduled before seekToTime.

    In preparation for seekWithoutAds:completionHandler:, disable autoPlay when setting up the BCOVPlaybackController.

    Apple recommends waiting for the status of an AVPlayerItem to change to ready-to-play before using the AVPlayerItem. Therefore, call seekWithoutAds:completionHandler: in the kBCOVPlaybackSessionLifecycleEventReady handler of the playbackController:playbackSession:didReceiveLifecycleEvent method of your BCOVPlaybackControllerDelegate.

    For details about seek without ads, see the following:

    • IMA
    • FreeWheel
    • Pulse implements seek without ads the same way as IMA or FreeWheel
    • SSAI