JWCaptionTrackBuilder

@objcMembers
public class JWCaptionTrackBuilder : NSObject, JWBuilder

The builder for creating a JWMediaTrack used for captions.

  • Declaration

    Swift

    public typealias Output = JWCaptionTrack
  • Builds a media track based off the settings provided.

    Throws

    throws An error if the track is not setup properly.

    Declaration

    Swift

    public func build() throws -> JWCaptionTrack
  • Sets the path to the caption track file.

    Note

    Accepts WebVTT, SRT, and TTML format, though JW Player strongly suggests using WEBVTT if possible.

    Declaration

    Swift

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

    Parameters

    file

    Path to the caption track file.

    Return Value

    The builder, so setters can be chained.

  • Sets the label to be shown in the player in the captions pop-up.

    Note

    Not shown if only 1 caption track is provided.

    Note

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

    Declaration

    Swift

    @discardableResult
    public func label(_ label: String) -> JWCaptionTrackBuilder

    Parameters

    label

    The label to be shown in the player in the captions pop-up.

    Return Value

    The builder, so setters can be chained.

  • Sets whether or not the player shows this caption track upon launch.

    Note

    The default value is false.

    Declaration

    Swift

    @discardableResult
    public func defaultTrack(_ defaultTrack: Bool) -> JWCaptionTrackBuilder

    Parameters

    defaultTrack

    Whether or not the player shows this caption track upon launch.

    Return Value

    The builder, so setters can be chained.

  • Sets the locale for the caption track.

    Declaration

    Swift

    @discardableResult
    public func locale(_ locale: String) -> JWCaptionTrackBuilder

    Parameters

    locale

    The ISO 639-1 code for the language in the caption track.

    Return Value

    The builder, so setters can be chained.