Inspect the playback timeline

You can obtain a description of the timeline associated with the currently selected item that is being played by the PSDK. This is most useful when your application displays a custom scrub-bar control in which the content sections that correspond to ad content are identified.

The PMPDemoApp reference implementation for the Android PSDK library implements this as follows and as seen in the following screen shot.


  1. Access the Timeline object in the MediaPlayer using the getTimeline method.

    The Timeline class encapsulates the information related to the contents of the timeline associated with the media item that is currently loaded by the MediaPlayer instance. The Timeline class gives access to a read-only view of the underlying timeline. The Timeline class provides a getter method that provides an iterator through a list of TimelineMarker objects.

  2. Iterate through the list of TimelineMarkers and use the returned information to implement your timeline.

    A TimelineMarker object contains two pieces of information:

    • The position of the marker on the timeline (in milliseconds)
    • The duration of the marker on the timeline (in milliseconds)
  3. Implement the listener callback interface MediaPlayer.PlaybackEventListener.onTimelineUpdated and register it with the Timeline object.
    The Timeline object can then inform your application about any changes that may occur in the playback timeline by calling your OnTimelineUpdated listener.
// access the timeline object
Timeline timeline = mediaPlayer.getTimeline();
// iterate through the list of TimelineMarkers
Iterator<TimelineMarker> iterator = timeline.timelineMarkers();
while (iterator.hasNext()) {
   TimelineMarker marker = iterator.next();
   // the start position of the marker
   long startPos = marker.getTime();
   // the duration of the marker
   long duration = marker.getDuration();
}