JWPlayerItemBuilder

@objcMembers
public class JWPlayerItemBuilder : NSObject, JWBuilder

The builder for JWPlayerItem, ensuring it is built correctly.

  • Declaration

    Swift

    public typealias Output = JWPlayerItem
  • Builds a JWPlayerItem modeled after the specified parameters.

    Throws

    JWError with key propertyNotSet If at least one video source is not specified. JWError with key ambiguousVideoSources If both a file and a video source are specified.

    Declaration

    Swift

    public func build() throws -> JWPlayerItem

    Return Value

    A JWPlayerItem object with the provided parameters.

  • Sets a single video source for the player item by providing an URL.

    Declaration

    Swift

    @discardableResult
    public func file(_ file: URL) -> JWPlayerItemBuilder

    Parameters

    file

    A String to display as title.

    Return Value

    The builder, so setters can be chained.

  • Sets the title of the player item.

    Note

    The string provided is displayed as a literal, and is not looked up in a localized string table.

    Declaration

    Swift

    @discardableResult
    public func title(_ title: String) -> JWPlayerItemBuilder

    Parameters

    title

    A String to display as title.

    Return Value

    The builder, so setters can be chained.

  • Sets the description of the player item.

    Note

    The string provided is displayed as a literal, and is not looked up in a localized string table.

    Declaration

    Swift

    @discardableResult
    public func description(_ description: String) -> JWPlayerItemBuilder

    Parameters

    description

    A String to display as description.

    Return Value

    The builder, so setters can be chained.

  • Sets the poster image url of the player item.

    Declaration

    Swift

    @discardableResult
    public func posterImage(_ posterImage: URL) -> JWPlayerItemBuilder

    Parameters

    posterImage

    An URL that points to the poster image.

    Return Value

    The builder, so setters can be chained.

  • Sets the number of seconds from the start of a media asset when playback should begin.

    Declaration

    Swift

    @discardableResult
    public func startTime(_ startTime: TimeInterval) -> JWPlayerItemBuilder

    Parameters

    startTime

    A TimeInterval value in seconds that determines the start of a media asset when playback should begin.

    Return Value

    The builder, so setters can be chained.

  • Sets the media identifier of the player item.

    Declaration

    Swift

    @discardableResult
    public func mediaId(_ mediaId: String) -> JWPlayerItemBuilder

    Parameters

    mediaId

    A String that represents the player item’s media identifier.

    Return Value

    The builder, so setters can be chained.

  • Sets the recommendations feed url that contains related items for a particular player item.

    Declaration

    Swift

    @discardableResult
    public func recommendations(_ recommendations: URL) -> JWPlayerItemBuilder

    Parameters

    recommendations

    An URL that represent the player item’s recommendations feed.

    Return Value

    The builder, so setters can be chained.

  • Sets the flag to start playng the player item automatically.

    Declaration

    Swift

    @available(*, deprecated, message: "Instead use JWPlayerConfigurationBuilder.autostart")
    @discardableResult
    public func autostart(_ autostart: Bool) -> JWPlayerItemBuilder

    Parameters

    autostart

    A Boolean that determines whether player item should start automatically after loading.

    Return Value

    The builder, so setters can be chained.

  • Sets the video sources which represent the quality levels of the player item.

    Declaration

    Swift

    @discardableResult
    public func videoSources(_ videoSources: [JWVideoSource]) -> JWPlayerItemBuilder

    Parameters

    videoSources

    An array of JWVideoSource objects representing multiple quality levels of a video.

    Return Value

    The builder, so setters can be chained.

  • Sets the media tracks which provide captions for different languages or thumbnails images of the player item.

    Declaration

    Swift

    @discardableResult
    public func mediaTracks(_ mediaTracks: [JWMediaTrack]) -> JWPlayerItemBuilder

    Parameters

    mediaTracks

    An array of JWMediaTrack objects providing captions for different languages or thumbnails images.

    Return Value

    The builder, so setters can be chained.

  • Sets a VMAP URL.

    Declaration

    Swift

    @discardableResult
    public func adSchedule(vmapURL: URL) -> JWPlayerItemBuilder

    Parameters

    vmapURL

    Either a local or remote URL of the vmap file.

    Return Value

    The builder, so setters can be chained.

  • Sets the advertising schedule which represents a point in the player item time to play the ad.

    Declaration

    Swift

    @discardableResult
    public func adSchedule(breaks: [JWAdBreak]) -> JWPlayerItemBuilder

    Parameters

    breaks

    An array of JWAdBreak objects providing captions for different languages or thumbnail images.

    Return Value

    The builder, so setters can be chained.

  • Sets URL asset .

    Note

    To see available options, refer to Initialization Options

    Declaration

    Swift

    @discardableResult
    public func assetOptions(_ assetOptions: [String : Any]) -> JWPlayerItemBuilder

    Parameters

    assetOptions

    A Dictionary of URLAsset initialization options.

    Return Value

    The builder, so setters can be chained.

  • Sets the Google DAI info which contains either a VoD or Live stream.

    Declaration

    Swift

    @discardableResult
    public func googleDAIStream(_ googleDAIStream: JWGoogleDAIStream) -> JWPlayerItemBuilder

    Parameters

    googleDAIStream

    A JWGoogleDAIStream object that provide info about either VoD or Live stream.

    Return Value

    The builder, so setters can be chained.

  • Sets an array of metadata that can be passed externally to supplement the encoded metadata of the underlying media asset.

    Note

    Supersedes the external metadata specified in the JWPlayerConfiguration, for this player item.

    Note

    Capped at 5 metadata instances; the instances in excess will be excluded.

    Declaration

    Swift

    @discardableResult
    public func externalMetadata(_ externalMetadata: [JWExternalMetadata]) -> JWPlayerItemBuilder

    Return Value

    The builder, so setters can be chained.

tvOS Extensions

  • Sets the skippable time ranges within the item.

    Declaration

    Swift

    @available(tvOS 14, *)
    @available(iOS, unavailable)
    @discardableResult
    func skippableTimeRanges(_ timeRanges: [JWSkippableTimeRange]) -> JWPlayerItemBuilder

    Parameters

    timeRanges

    The time ranges which the user can skip.

    Return Value

    The builder, so setters can be chained.