setPlayheadPosition()

From Engineering Client Portal

Revision as of 19:33, 30 November 2018 by Admin (talk | contribs)

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png Android SDK API Reference breadcrumbArrow.png setPlayheadPosition()
For situations where CMS data is used in conjunction with Nielsen’s SDK, the application needs to call the setPlayheadPosition in the SDK every one second. For proper reporting, the SDK should

  • Receive a playhead position update every one second on the playback of content.
  • Not receive playhead updates when the content playback is paused or stopped.

When streaming VOD (Video On Demand), the playhead position is the current location of the player from the beginning of the asset in seconds; When streaming live content, the playhead position passed to the AppSdk is the current Unix timestamp (seconds since Jan-1-1970 UTC). For Digital Audio streaming Live or On Demand content, the playhead position passed to the AppSdk is the current Unix timestamp (seconds since Jan-1-1970 UTC)

Syntax

public void setPlayheadPosition(long position)

Input Parameters

Parameter Description
playhead position An Integer value representing the time in content in seconds (VOD – Video On Demand) or the current Unix timestamp (seconds since Jan-1-1970 UTC) (live).

Output Parameters

Output Parameters (Return value) Description
void

Notes

The player application must send the value of the playhead to the SDK every one second. The player application can schedule a timer with a one-second-period in a timer event and send the playhead position. The client app can schedule a one-second-period timer to send the playhead position in the following manner:

Scheduling a one-second-period timer

//The client app can schedule a one-second-period timer to send the playhead position in the following manner.
class PlayerPositionTracker extends Thread implements Runnable
{
   public static final int POSITON_INTERVAL = 1000;
   @Override
   public void run()
   {
      while (true)
      {
         long t = 0;
         if (isPlaying)
         {
            if (isLive) // Live – dependent on media player
            {
               t = (c.getTimeInMillis()/ 1000;
               if (mAppSdk != null)
                   mAppSdk.setPlayheadPosition(t);
            }
            else // VOD
            {
               t = mMediaPlayer.getCurrentPosition() / 1000;
               if (mAppSdk != null)
                  mAppSdk.setPlayheadPosition(t);
            }
         }
           Thread.sleep(POSITON_INTERVAL);
      }
   }
}