Class PlaylistItem.Builder

java.lang.Object
com.jwplayer.pub.api.media.playlists.PlaylistItem.Builder
Enclosing class:
PlaylistItem

public static class PlaylistItem.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
    • Builder

      public Builder(PlaylistItem src)
  • Method Details

    • title

      public PlaylistItem.Builder title(String title)
      Parameters:
      title - Title of the item. This is displayed inside of the player prior to playback, as well as in the visual playlist. This can be hidden with the PlayerConfig.setDisplayTitle() option.
    • description

      public PlaylistItem.Builder description(String description)
      Parameters:
      description - Short description of the item. It is displayed below the title. This can be hidden with the PlayerConfig.setDisplayDescription() option.
    • file

      public PlaylistItem.Builder file(String file)
      Parameters:
      file - The media file for this playlist item.
    • image

      public PlaylistItem.Builder image(String image)
      Parameters:
      image - Poster image URL. Displayed before and after playback.
    • mediaId

      public PlaylistItem.Builder mediaId(String mediaId)
      Parameters:
      mediaId - Unique identifier of this item. Used by advertising, analytics and discovery services.
    • feedId

      public PlaylistItem.Builder feedId(String feedId)
      Parameters:
      feedId - Unique identifier of this item. Used by Related/Recommendation services.
    • recommendations

      public PlaylistItem.Builder recommendations(String recommendations)
      Parameters:
      recommendations - URL to a feed that contains related items for a particular playlist item.
    • sources

      public PlaylistItem.Builder sources(List<MediaSource> sources)
      Parameters:
      sources - Used for quality toggling and alternate sources.
    • tracks

      public PlaylistItem.Builder tracks(List<Caption> tracks)
      Parameters:
      tracks - Include captions, chapters, and thumbnails for media.
    • adSchedule

      public PlaylistItem.Builder adSchedule(List<AdBreak> adSchedule)
      Parameters:
      adSchedule - Schedule advertising for a specific media file.
    • adSchedule

      public PlaylistItem.Builder adSchedule(String vmapUrlOrXML)
      Parameters:
      vmapUrlOrXML - Either a local, remote URL of the vmap file, or a VMAP (XML) string.
    • mediaDrmCallback

      public PlaylistItem.Builder mediaDrmCallback(MediaDrmCallback callback)
      Parameters:
      callback - DRM callback instance -- used for Widevine DRM.
    • drmConfig

      public PlaylistItem.Builder drmConfig(DrmConfig drmConfig)
    • userInfo

      public PlaylistItem.Builder userInfo(JSONObject userInfo)
      Parameters:
      userInfo - JSONObject containing information to be passed to Chromecast receivers.
      Avoid keyword `sources` if using Studio DRM
    • imaDaiSettings

      public PlaylistItem.Builder imaDaiSettings(ImaDaiSettings imaDaiSettings)
    • externalMetadata

      public PlaylistItem.Builder externalMetadata(List<ExternalMetadata> externalMetadata)
    • httpHeaders

      public PlaylistItem.Builder httpHeaders(Map<String,String> httpHeaders)
      Parameters:
      httpHeaders - HTTP Headers to include with requests for this media file.
    • startTime

      public PlaylistItem.Builder startTime(double startTime)
      Parameters:
      startTime - value that defines the start time for playlist items
    • duration

      public PlaylistItem.Builder duration(int durationInSeconds)
      Parameters:
      durationInSeconds - value used to display the duration of the video
    • liveSyncDuration

      public PlaylistItem.Builder liveSyncDuration(double liveSyncDuration)
      Sets the target live sync duration for live stream playback.

      This controls how far behind the live edge (in seconds) the player targets during live stream playback (it sets the live target offset; the player still applies its normal correction band around it). A larger offset means the player sits further behind live, which can give downstream processing (e.g. caption handling) more lead time — it does not by itself alter how or when captions are decoded.

      Example:

      
       PlaylistItem item = new PlaylistItem.Builder()
           .file("https://example.com/live/stream.m3u8")
           .liveSyncDuration(15.0)  // Target 15 seconds behind live edge
           .build();
       

      Behavior:

      • Values are clamped to the range 5-45 seconds. Values below 5 are set to 5; values above 45 are set to 45.
      • A value of 0 (or negative) means unset — the player uses its default behavior.
      • This setting only affects live streams; it is ignored for VOD content.
      • This overrides any target offset hints from the stream manifest (e.g., HLS EXT-X-SERVER-CONTROL).

      Risks: Higher values increase the delay between the live broadcast and the viewer. For latency-sensitive content, use the lowest value that meets your needs. Very low values (near 5s) may cause buffering on poor networks.

      Parameters:
      liveSyncDuration - The target offset in seconds behind the live edge. Use 0 to leave unset (default behavior). Clamped to 5-45s.
      Returns:
      This builder for chaining.
      See Also:
    • build

      public PlaylistItem build()