support Contact Support | system status System Status
Page Contents

    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 lets you start watching a video on one device, and at a later time, continue watching the video where you left off on a different device.

    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, you will 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 user 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, "user 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 user playback position from the Cross-Device Resume (XDR) API.

      For details, see the following:

    3. Resume playback.

      Once you get the user 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(<user 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.user id,
            @"privateApplication": @"application id"
          }
          forKey:@"privateSessionAnalytics"];
        }
        @catch (NSException *e)
        {
          NSLog(@"%@", e.description);
        }
      
    2. Get the user playback position from the Cross-Device Resume (XDR) API.

      For details, see the following:

    3. Resume playback.

      Once you get the user 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 user 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

    Page last updated on 29 Jul 2020