• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

Timeshift

KreaTV supports recording the video stream the end-user is currently viewing, allowing them to pause and rewind. The process is a little bit different depending on whether you are using an ARRIS-approved storage device or not.

ARRIS-approved storage devices, such as the DVR-One hard disk unit, are already prepared for Timeshift usage. Non ARRIS-approved devices will need to be prepared before use. See the section on DVR and Timeshift support for more information on preparing devices.

This tutorial assumes you are using a DVR-One unit.

Subscribing to events

Since KreaTV supports hot plugging and disconnecting devices at any time, the example portal subscribes to the ON_CAPABILITIES_CHANGED event, which is triggered whenever the capabilities of the current stream change.

<sdk_root>/examples/example-html-portal/timeshift.js

function subscribeToMediaEvents() {
  mediaPlayer.addEventListener(
    toi.consts.ToiMediaPlayerBase.ON_CAPABILITIES_CHANGED,
    onMediaPlayerCapabilitiesChanged);
  mediaPlayer.addEventListener(
    toi.consts.ToiMediaPlayerBase.ON_TIMESHIFT_STATE_CHANGED,
    onTimeshiftStateChanged);
}

When the capabilities of the current stream change, the portal checks to see the status of the CAPABILITY_TIMESHIFT flag:

<sdk_root>/examples/example-html-portal/timeshift.js

function onMediaPlayerCapabilitiesChanged(event) {
 if ((event.capabilityMask &
      toi.consts.ToiMediaPlayerBase.CAPABILITY_TIMESHIFT) !== 0 &&
      !startTimer) {
    startTimer = setTimeout(startTimeshiftNow, 5000);
  }
}

On detecting that the stream capabilities have changed, and that timeshift is possible, the example portal waits a few seconds and then starts timeshift recording. This delay is there to prevent starting/stopping timeshift when the end-user zaps through several channels quickly, which can impact performance.

If you want to poll at any time to see if timeshift is supported, call the ToiMediaPlayerBase.getCapabilities() function. This checks to see if timeshift is supported for the currently playing stream. You can also check the configuration object VAR_CAPABILITIES_TIMESHIFT to see if the system supports timeshift in general (indicating that the license and storage device are present and ready).

When timeshift begins, another ON_CAPABILITIES_CHANGED event occurs as pause and rewind capabilities become available.

Starting timeshift

After the short delay has expired, the function below is executed:

<sdk_root>/examples/example-html-portal/timeshift.js

function startTimeshiftNow() {
  ...

  var maxTimeshiftLength = parseInt(toi.informationService.get(
    [toi.consts.ToiInformationService.
     CONST_MEDIA_TIMESHIFTBUFFER_CONFIGTIME])[0].objectItem.value);

  mediaPlayer.startTimeshiftBuffering(maxTimeshiftLength);

}

It gets the maximum permitted length for the timeshift buffer (may depend on whether the license file is included or not) and calls ToiMediaPlayer.startTimeshiftBuffering().

The example portal does not explicitly stop timeshift buffering, since recordings are always circular. When zapping channels, timeshifting will be automatically stopped by the KreaTV platform.

More information and options for controlling timeshift behavior are available through the CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY and CFG_MEDIA_TIMESHIFT_PLAYBACKPOLICY configuration objects.

5.1.1.p8

Copyright (c) 2018 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.