JWPlayerViewController
@objcMembers
@MainActor
open class JWPlayerViewController: UIViewController,
RelatedEventDelegate,
AVPictureInPictureControllerDelegate,
InternalEventHandlerDelegate,
JWPlayerViewDelegate,
JWPlayerDelegate,
JWPlayerStateDelegate,
JWAVDelegate,
JWAdDelegate,
JWAirPlayDelegate,
JWAccessLogMetadataDelegate,
JWDateRangeMetadataDelegate,
JWID3MetadataDelegate,
JWExternalMetadataDelegate,
JWProgramDateTimeMetadataDelegate,
JWMediaMetadataDelegate,
JWCastDelegate,
JWTimeEventListener,
JWChaptersDelegate,
JWRelatedEventDelegate,
MenuPresenter,
UIPopoverPresentationControllerDelegate
This ViewController creates a JWPlayerView
, and creates a default interface for the content.
If you are using JWPlayerViewController
, do not assign another class as a delegate for JWPlayerView
or JWPlayer
and its related delegate properties, nor for JWPlayer.adTimeObserver
and JWPlayer.mediaTimeObserver
. This controller conforms to these delegates already. You can gain access to events by subclassing this, and overriding the methods you are interested in.
Note
If you are writing in Objective-C and want to subclass this ViewController, refer toJWPlayerObjViewController
and subclass that instead.
-
A Boolean value that determines whether the player view allows Picture in Picture playback.
Note
The default value istrue
.Attention
canStartPictureInPictureAutomaticallyFromInline
is not set to true when enabling this property, Picture-in-Picture mode should only be expected to be initiated when using the UI button designated for this.Declaration
Swift
@MainActor public var allowsPictureInPicturePlayback: Bool { get set }
-
The delegate to receive JWPlayerViewControllerFullscreen events.
Declaration
Swift
@MainActor public weak var fullScreenDelegate: JWPlayerViewControllerFullScreenDelegate?
-
The delegate to receive JWPlayerViewControllerUI events.
Declaration
Swift
@MainActor public weak var uiDelegate: JWPlayerViewControllerUIDelegate?
-
The delegate to receive JWPlayerViewControllerRelated events.
Declaration
Swift
@MainActor public weak var relatedDelegate: JWPlayerViewControllerRelatedDelegate?
-
Returns true if the player is currently in fullscreen mode, and false if it is not
Declaration
Swift
@MainActor public var isFullScreen: Bool { get }
-
The view containing the player.
Warning
Do not access this until the view is loaded.Declaration
Swift
@MainActor public var playerView: JWPlayerViewProtocol! { get }
-
The behavior desired for the interface. The default value is
.normal
.Declaration
Swift
@MainActor public var interfaceBehavior: JWInterfaceBehavior { get set }
-
Available playback rates.
This property is automatically sorted. If an empty array is specified, 1.0 becomes the only available option. Rates must be greater than 0 and less than or equal to 4.0. Invalid rates are removed from the array.
The default rates are: [0.5, 1.0, 1.25, 1.5, 2.0]
Declaration
Swift
@MainActor public var playbackRates: [Double] { get set }
-
It enables the lock screen controls to be synchronized with the player. The default is
true
.Declaration
Swift
@MainActor public var enableLockScreenControls: Bool { get set }
-
The number of seconds to wait when fading the interface. The default is 3 seconds.
Note
This only applies wheninterfaceBehavior
is .normal.Declaration
Swift
@MainActor public var interfaceFadeDelay: TimeInterval
-
The poster image to display when there is no Internet connection. By default, it displays the poster image of the current video.
Declaration
Swift
@MainActor public var offlinePosterImage: UIImage? { get set }
-
The message that is displayed when the internet connection is lost.
The default value is “This video cannot be played because of a problem with your internet connection.” which corresponds to the localizable string [jwplayer_errors_bad_connection].
Declaration
Swift
@MainActor public var offlineMessage: String { get set }
-
Returns a Boolean indicating whether to automatically create Chromecast-related UI and update the UI based on Chromecast events.
Override this property in a subclass to signal your intention to not rely on the SDK’s default Chromecast UI integration.
Declaration
Swift
@MainActor open var handleCastingInternally: Bool { get }
Return Value
true
if yourJWPlayerViewController
subclass lets the SDK handle Chromecast-related UI creation and updates, orfalse
if you intend to display on your own custom UI instead. The default value of this property returnstrue
. -
The JWPlayer interface, used to control playback and configure the player.
Warning
Do not access this until theplayerView
is loaded.Declaration
Swift
@MainActor public var player: JWPlayerProtocol! { get }
-
The default ad interface style to use when presenting JWP VAST ads.
Declaration
Swift
@MainActor public var adInterfaceStyle: JWAdInterfaceStyle
-
If true, the player will go full screen when rotated into landscape orientation. The default value is
true
.Declaration
Swift
@MainActor public var forceFullScreenOnLandscape: Bool
-
If true, the player rotates into landscape when it goes into fullscreen. The default value is
true
.Declaration
Swift
@MainActor public var forceLandscapeOnFullScreen: Bool
-
The style used to customize the player.
Declaration
Swift
@MainActor public var styling: JWPlayerSkin? { get set }
-
Indicates whether or not the description should be displayed. The default value is
true
.Declaration
Swift
@MainActor public var descriptionIsVisible: Bool { get set }
-
Indicates whether or not the title should be displayed. The default value is
true
.Declaration
Swift
@MainActor public var titleIsVisible: Bool { get set }
-
The style defining the Next Up card and its behavior.
Note
If nil is set no Next Up card will be displayed.Declaration
Swift
@MainActor public var nextUpStyle: JWNextUpStyle? { get set }
-
Sets a custom logo to display on the player.
Declaration
Swift
@MainActor public var logo: JWLogo? { get set }
-
Called after the controller’s view is loaded into memory. For more information, refer to
UIViewController
documentation.Declaration
Swift
@MainActor open override func viewDidLoad()
-
Undocumented
Declaration
Swift
@MainActor open override func viewWillLayoutSubviews()
-
Called after the view controller is added or removed from a container view controller. For more information, refer to
UIViewController
documentation.Declaration
Swift
@MainActor open override func didMove(toParent parent: UIViewController?)
Parameters
parent
The parent view controller, or nil if there is no parent.
-
Sets the visibility of specified controls within the player’s interface.
This function allows for the dynamic showing or hiding of user interface controls, such as buttons, sliders, or menus. It provides a flexible way to adapt the player’s interface based on user interaction, content type, or other criteria.
Note
Calling this before the view has loaded will have no effect.Declaration
Swift
@MainActor public func setVisibility(_ visibility: JWVisibilityState, for controls: [JWControlType])
Parameters
visibility
The desired visibility state (
JWVisibilityState
) for the specified controls.controls
The specific player controls to which the visibility state will be applied.
-
Notifies the container that the size of its view is about to change. For more information, refer to
UIViewController
documentation.Declaration
Swift
@MainActor open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
Parameters
size
The new size for the container’s view.
coordinator
The transition coordinator object managing the size change. You can use this object to animate your changes or get information about the transition that is in progress.
-
This method transitions the player to fullscreen mode. If the player is already in fullscreen mode this method does not perform any actions, and the completion closure will not be executed.
Declaration
Swift
@MainActor public func transitionToFullScreen(animated: Bool, completion: (() -> Void)? = nil)
Parameters
animated
Set to true if the player should animate into full screen.
completion
This closure is called when the player is done transitioning to full screen mode.
-
This method transitions the player away from fullscreen mode. If the player is not in fullscreen mode this method does not perform any actions, and the completion closure will not be executed.
Declaration
Swift
@MainActor public func dismissFullScreen(animated: Bool, completion: (() -> Void)? = nil)
Parameters
animated
Set to true if the player should animate away from full screen mode.
completion
This closure is called when the player is done transitioning away from full screen mode.
-
Declaration
Swift
@MainActor open func playerView(_ view: JWPlayerView, sizeChangedFrom oldSize: CGSize, to newSize: CGSize)
-
Declaration
Swift
@MainActor open func jwplayerIsReady(_ player: JWPlayer)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, failedWithError code: UInt, message: String)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, failedWithSetupError code: UInt, message: String)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, encounteredWarning code: UInt, message: String)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, encounteredAdError code: UInt, message: String)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, encounteredAdWarning code: UInt, message: String)
-
Declaration
Swift
@MainActor open func onMediaTimeEvent(_ time: JWTimeData)
-
Declaration
Swift
@MainActor open func onAdTimeEvent(_ time: JWTimeData)
-
Declaration
Swift
@MainActor open func jwplayerContentWillComplete(_ player: JWPlayer)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, willPlayWithReason reason: JWPlayReason)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, isBufferingWithReason reason: JWBufferReason)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, updatedBuffer percent: Double, position time: JWTimeData)
-
Declaration
Swift
@MainActor open func jwplayerContentDidComplete(_ player: JWPlayer)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, didFinishLoadingWithTime loadTime: TimeInterval)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, isPlayingWithReason reason: JWPlayReason)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, isAttemptingToPlay playlistItem: JWPlayerItem, reason: JWPlayReason)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, didPauseWithReason reason: JWPauseReason)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, didBecomeIdleWithReason reason: JWIdleReason)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, usesMediaType type: JWMediaType)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, isVisible: Bool)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, didLoadPlaylist playlist: [JWPlayerItem])
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, didLoadPlaylistItem item: JWPlayerItem, at index: UInt)
-
Declaration
Swift
@MainActor open func jwplayerPlaylistHasCompleted(_ player: JWPlayer)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, seekedFrom oldPosition: TimeInterval, to newPosition: TimeInterval)
-
Declaration
Swift
@MainActor open func jwplayerHasSeeked(_ player: JWPlayer)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, playbackRateChangedTo rate: Double, at time: TimeInterval)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, didReceiveAccessLogMetadata metadata: JWAccessLogMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, dateRangeMetadataCueParsed metadata: JWDateRangeMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, dateRangeMetadata metadata: JWDateRangeMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, id3Metadata metadata: JWID3Metadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, externalMetadataCueParsed metadata: JWExternalMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, externalMetadata metadata: JWExternalMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, programDateTimeMetadataCueParsed metadata: JWProgramDateTimeMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, programDateTimeMetadata metadata: JWProgramDateTimeMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, didReceiveMediaMetadata metadata: JWMediaMetadata)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, airPlayStatusChanged status: JWAirPlayStatus)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, audioTracksUpdated levels: [JWMediaSelectionOption])
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, audioTrackChanged currentLevel: Int)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, qualityLevelsUpdated levels: [JWVideoSource])
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, qualityLevelChanged currentLevel: Int)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, visualQualityChanged currentVisualQuality: JWVisualQuality)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, updatedCaptionList options: [JWMediaSelectionOption])
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, captionTrackChanged index: Int)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, captionPresented caption: [String], at time: JWTimeData)
-
Tells the delegate when Picture in Picture is about to start.
Declaration
Swift
@MainActor open func pictureInPictureControllerWillStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController)
Parameters
pictureInPictureController
The Picture in Picture controller to which you’ve assigned the delegate.
-
Tells the delegate that Picture in Picture playback has started.
Declaration
Swift
@MainActor open func pictureInPictureControllerDidStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController)
Parameters
pictureInPictureController
The Picture in Picture controller to which you’ve assigned the delegate.
-
Tells the delegate when Picture in Picture is about to stop.
Declaration
Swift
@MainActor open func pictureInPictureControllerWillStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController)
Parameters
pictureInPictureController
The Picture in Picture controller to which you’ve assigned the delegate.
-
Tells the delegate when Picture in Picture playback stops.
Declaration
Swift
@MainActor open func pictureInPictureControllerDidStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController)
Parameters
pictureInPictureController
The Picture in Picture controller to which you’ve assigned the delegate.
-
Tells the delegate when Picture in Picture is about to stop, to give your app an opportunity to restore its video playback user interface.
Note
Make sure to call the completion handler when you have restored the UI, it is important to notify the system of this.Declaration
Swift
@MainActor open func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void)
Parameters
pictureInPictureController
The Picture in Picture controller to which you’ve assigned the delegate.
completionHandler
To allow the system to finish restoring your user interface, you must call the completion handler with a value of
true
. -
Tells the delegate whether Picture in Picture failed to start.
Declaration
Swift
@MainActor open func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, failedToStartPictureInPictureWithError error: Error)
Parameters
pictureInPictureController
The Picture in Picture controller to which you’ve assigned the delegate.
error
An error describing why Picture in Picture failed to start.
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, devicesAvailable devices: [JWCastingDevice])
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, connectedTo device: JWCastingDevice)
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, disconnectedWithError error: Error?)
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, connectionSuspendedWithDevice device: JWCastingDevice)
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, connectionRecoveredWithDevice device: JWCastingDevice)
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, connectionFailedWithError error: Error)
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, castingBeganWithDevice device: JWCastingDevice)
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, castingFailedWithError error: Error)
-
Declaration
Swift
@MainActor open func castController(_ controller: JWCastController, castingEndedWithError error: Error?)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, loadedRelatedPlaylist playlist: [JWPlayerItem])
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, loadedNextUpItem item: JWPlayerItem)
-
Declaration
Swift
@MainActor open func jwplayer(_ player: JWPlayer, relatedItemBeganPlaying item: JWPlayerItem, atIndex index: Int, withMethod method: JWRelatedMethod)
-
Asks the delegate for the presentation style to use when the specified set of traits are active.
Declaration
Swift
@MainActor public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle
Parameters
controller
The presentation controller that is managing the size change. Use this object to retrieve the view controllers involved in the presentation.
traitCollection
The traits representing the target environment.
-
Notifies the delegate that an adaptivity-related transition is about to occur.
Declaration
Swift
@MainActor public func presentationController(_ presentationController: UIPresentationController, willPresentWithAdaptiveStyle style: UIModalPresentationStyle, transitionCoordinator: UIViewControllerTransitionCoordinator?)
Parameters
presentationController
The presentation controller that is managing the adaptivity change.
style
The new presentation style. If the presentation style is not changing, this parameter is set to
UIModalPresentationStyle.none
.transitionCoordinator
The transition coordinator that is managing the transition.
-
Sets the visibility of controls on the player’s interface.
Use the
JWControlType
enum to initialize aNSNumber
object with the desired control type.[controller setVisibility:FALSE forControls:@[@(JWControlTypePictureInPictureButton)]]