<img src="https://img.shields.io/badge/%20-ENTERPRISE-B10031" style="float:left"/><br /> <img src="https://img.shields.io/badge/iOS-V4-009727?logo=apple" style="float:left"/><br />

To set up a player, use `JWPlayerViewController`(iOS). Like any `UIViewController`, our view controller can be presented in the following ways:

  • Presented directly (full screen)

  • Embedded in a container view (partial screen)

The view controller uses the default JWP user interface. If you subclass the view controller, you can listen for all of the events related to the player and the user interface.

<br /> <hr />

## Implementation

Use the following steps to set up a player with the `JWPlayerViewController`:

iOS: Set Up a Player
Open Recipe

<br /> <hr />

## Using Player APIs

### Content Handling APIs

To use the player content handling APIs, the `playerIsReady` (<a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWPlayerViewController.html#/c:@M@JWPlayerKit@objc(pl)JWPlayerDelegate(im)jwplayerIsReady:" target="_blank">iOS</a>) event must have already been initiated. The `playerIsReady` event is called once the player property of the `JWPlayerViewController` object has finished setup. Then, the event is sent to the `JWPlayerDelegate`.

Unless set to another object, the `JWPlayerDelegate` is set to the `JWPlayerViewController`.


When subclassing either view controller, <strong>do not override the delegates in `JWPlayerView` or `JWPlayer`</strong>.

<br />

Values related to the currently loaded item such as `player.currentItem` will be set once the `didLoadPlaylistItem` delegate method is called.


<br />

The content handling APIs are listed below:

β€’ `func forward(seconds: TimeInterval)`<br /><br />β€’ `func getState() -> JWPlayerState`<br /><br />β€’ `func loadPlayerItemAt(index: Int)`<br /><br />β€’ `func loadPlaylist(_ playlist: [JWPlayerItem])`<br /><br />β€’ `func next()`<br /><br />β€’ `func pause()`<br /><br />β€’ `func play()`<br /><br />β€’ `func play(ad tag: URL, client: JWAdClient)`<br /><br />β€’ `func previous()`<br /><br />β€’ `func rewind(seconds: TimeInterval)`<br /><br />β€’ `func seek(to seconds: TimeInterval)`<br /><br />β€’ `func skipAd()`<br /><br />β€’ `func stop()`β€’ `var currentItem: JWPlayerItem? {get}`<br /><br />β€’ `var playbackRate: Double { get set }`<br /><br />β€’ `var time: JWTimeData { get }`<br /><br />β€’ `var volume: Double { get set }`

<br />

### Non-content Handling APIs

APIs that do not relate to content handling can be accessed and used prior to the `playerIsReady` event being initiated.

The non-content handling APIs are listed in the following table.

FunctionEvent Delegates
β€’ `func configurePlayer(with configuration: JWPlayerConfiguration)`β€’ `delegate: JWPlayerDelegate? { get set }`<br /><br />β€’ `var contentKeyDataSource: JWDRMContentKeyDataSource? { get set }`<br /><br />β€’ `var playbackStateDelegate: JWPlayerStateDelegate? { get set }`<br /><br />β€’ `var adDelegate: JWAdDelegate? { get set }`<br /><br />β€’ `var adTimeObserver: ((JWTimeData) -> Void)? { get set }`<br /><br />β€’ `var airPlayDelegate: JWAirPlayDelegate? { get set }`<br /><br />β€’ `var avDelegate: JWAVDelegate? { get set }`<br /><br />β€’ `var friendlyObstructions: JWFriendlyObstructionManager { get }`<br /><br />β€’ `var mediaTimeObserver: ((JWTimeData) -> Void)? { get set }`<br /><br />β€’ `var metadataDelegates: JWMetadataDelegates { get }`

<br />

(Script tags will be stripped)