JWPlayerConfigurationBuilder
@objcMembers
public final class JWPlayerConfigurationBuilder : NSObject, JWBuilder, JWJSONDecodable
Used to build a JWPlayerConfiguration
object to configure instance(s) of JWPlayer
.
-
Declaration
Swift
public typealias Output = JWPlayerConfiguration
-
Returns a
JWPlayerConfigurationBuilder
instance with initial values equal to a valid JSON representation of a player configuration.These values can still be subsequently assigned. For example, to overwrite a player’s autostart setting, retaining all other values:
let playerConfig = try! JWPlayerItemBuilder(from: sourcePlayerConfigurationJsonObject) .autostart(true) .build()
Declaration
Swift
public convenience init?(from json: JSONObject)
Parameters
json
The
JSONObject
from which the builder will copy values. Must be valid. -
Builds player config based off the settings provided.
Throws
throws An error if the config is not setup properly.Declaration
Swift
public func build() throws -> JWPlayerConfiguration
-
Sets an array of
JWPlayerItem
objects containing information about different media items to be reproduced in a sequence.See also
JWPlayerItem
Declaration
Swift
@discardableResult public func playlist(items: [JWPlayerItem]) -> JWPlayerConfigurationBuilder
Parameters
items
An array of
JWPlayerItem
objects containing information about different media items to be reproduced in a sequence.Return Value
The builder, so setters can be chained.
-
Sets an array of
JWPlayerItem
objects containing information about different media items to be reproduced in a sequence.See also
JWPlayerItem
Declaration
Swift
@available(*, deprecated, renamed: "playlist(items:﹚") @discardableResult public func playlist(_ playlist: [JWPlayerItem]) -> JWPlayerConfigurationBuilder
Parameters
playlist
An array of
JWPlayerItem
objects containing information about different media items to be reproduced in a sequence.Return Value
The builder, so setters can be chained.
-
Sets the playlist content url using a URL.
Declaration
Swift
@discardableResult public func playlist(url: URL) -> JWPlayerConfigurationBuilder
Parameters
url
The URL of the playlist content.
Return Value
The builder, so setters can be chained.
-
Sets the settings that control the behavior of ads.
See also
JWAdvertisingConfig
Declaration
Swift
@discardableResult public func advertising(_ advertising: JWAdvertisingConfig) -> JWPlayerConfigurationBuilder
Parameters
advertising
Information about ad behavior.
Return Value
The builder, so setters can be chained.
-
Sets the settings for related content.
See also
JWRelatedConfig
Declaration
Swift
@discardableResult public func related(_ related: JWRelatedContentConfiguration) -> JWPlayerConfigurationBuilder
Parameters
related
Settings for related content.
Return Value
The builder, so setters can be chained.
-
Sets whether or not a video should start automatically after loading. The default value is
false
.Declaration
Swift
@discardableResult public func autostart(_ autostart: Bool) -> JWPlayerConfigurationBuilder
Parameters
autostart
Whether or not a video should start automatically after loading.
Return Value
The builder, so setters can be chained.
-
Sets whether or not content should be loaded prior to playback. The default value is
JWPreload.auto
.Note
JWPreload.auto
loads the manifest before playback is requested.Note
JWPreload.none
doesn’t preload content. We recommend this if you are concerned about excess content usage.Declaration
Swift
@discardableResult public func preload(_ preload: JWPreload) -> JWPlayerConfigurationBuilder
Parameters
preload
Whether or not the content should be loaded prior to playback.
Return Value
The builder, so setters can be chained.
-
Sets the maximum bitrate that can be reached during automatic quality switching. Useful for limiting bandwidth consumption by viewers.
Note
If network bandwith usage cannot be reduced to meet the bitrateUpperBound, it will be lowered as much as possible while continuing playback.Declaration
Swift
@discardableResult public func bitrateUpperBound(_ bitrateUpperBound: Float) -> JWPlayerConfigurationBuilder
Parameters
bitrateUpperBound
The maximum bitrate that can be reached during automatic quality switching.
Return Value
The builder, so setters can be chained.
-
Sets whether or not content should repeat after it’s done playing. The default value is
false
.Declaration
Swift
@discardableResult public func repeatContent(_ repeatContent: Bool) -> JWPlayerConfigurationBuilder
Parameters
repeatContent
Whether or not content should repeat after it’s done playing.
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
Applies to all playlist items that do not specify their own external metadata.Note
Capped at 5 metadata instances; the instances in excess will be excluded.See also
JWExternalMetadata
Declaration
Swift
@discardableResult public func externalMetadata(_ externalMetadata: [JWExternalMetadata]) -> JWPlayerConfigurationBuilder
Parameters
externalMetadata
An array of metadata to apply.
Return Value
The builder, so setters can be chained.
-
Defines what ad tracking library to use for analytics.
Declaration
Swift
@discardableResult public func adTracker(_ tracker: JWAdTrackerConfig) -> JWPlayerConfigurationBuilder
Parameters
tracker
A config for the desired ad tracker.
-
Defines what settings to use during external playback.
Declaration
Swift
@discardableResult public func externalPlaybackSettings(_ settings: JWExternalPlaybackSettings) -> JWPlayerConfigurationBuilder
Parameters
settings
The settings object defining external playback behavior.
-
Sets the player’s “Dashboard Player Configuration Key” (
pid
) used by JWDashboard analytics.Warning
Must be an 8-char alphanumeric, otherwise callingbuild()
will throw a warning.Precondition
The playerID must already exist in the JW Dashboard property associated with the License Key, or else it will be ignored by the analytics platform.Note
Not to be confused with the JS player’sid
property, which is a reference used to tag the actual element/object (such as thediv
in a web browser context).Declaration
Swift
@discardableResult public func playerId(_ playerId: String) -> JWPlayerConfigurationBuilder
Return Value
The builder, so setters can be chained.
-
Allows a configuration to be created using a natively-defined JSONObject.
Warning
If this method is called, it will override any parameters set using other methods in this builder. Callingconfiguration(json: Data)
will throw an error whenbuild()
is called.Declaration
Swift
@discardableResult public func configuration(json: JSONObject) -> JWPlayerConfigurationBuilder
Parameters
json
The dictionary defining the configuration.
-
Allows a configuration to be created using a data blob containing JSON. If the supplied data cannot be converted into JSON, or the JSON in the data is not formatted correctly, the
build()
method will throw an error.Warning
If this method is called, it will override any parameters set using other methods in this builder. Callingconfiguration(json: JSONObject)
will throw an error whenbuild()
is called.Declaration
Swift
@discardableResult public func configuration(data: Data) -> JWPlayerConfigurationBuilder
Parameters
data
The JSON data defining the configuration.