JWAdOffset

@objc
public class JWAdOffset : NSObject

An offset into the content where an ad plays.

  • Creates a preroll offset.

    Declaration

    Swift

    @objc
    public static func preroll() -> JWAdOffset

    Return Value

    A new instance of JWAdOffset.

  • Creates a postroll offset.

    Declaration

    Swift

    @objc
    public static func postroll() -> JWAdOffset

    Return Value

    A new instance of JWAdOffset.

  • Creates a midroll offset.

    Declaration

    Swift

    @objc
    public static func midroll(seconds: TimeInterval) -> JWAdOffset

    Parameters

    seconds

    The number of seconds into the video where the ad occurs. If this is less than or equal to 0, it will return a preroll.

    Return Value

    A new instance of JWAdOffset.

  • Creates a midroll offset.

    Declaration

    Swift

    @objc
    public static func midroll(percent: Int) -> JWAdOffset

    Parameters

    percent

    A percentage (0-100) into the content’s duration where the ad occurs. Any value 0 or below is considered a preroll, and if it is 100 or above, it is considered a postroll.

    Return Value

    A new instance of JWAdOffset.

  • Creates a JWAdOffset from a supplied string.

    This method requires the supplied string be in one of the a few specific formats.

    • “pre”: Creates a preroll.
    • “mid”: Creates a midroll 50% into the content.
    • “post”: Creates a postroll.
    • “[FLT]”: A midroll at a number of seconds into the content. e.g. “3.5”
    • “[INT]%”: A midroll at a percentage of the way into the content. Valid values range from 0-100. e.g. “50%”
    • “[Hours]:[Minutes]:[Seconds]”: A specified time in the content at which to have a midroll. e.g. “3:45”, “02:23:06”, etc.

    Declaration

    Swift

    @objc
    public static func from(string val: String) -> JWAdOffset?

    Parameters

    val

    The string to parse for an offset value.

    Return Value

    A new instance of JWAdOffset, or nil if the string is an invalid value.

  • Returns a string describing the offset’s value.

    Declaration

    Swift

    @objc
    public func asString() -> String

    Return Value

    The offset’s value as a string.