MobilePlayerViewController

public class MobilePlayerViewController: MPMoviePlayerViewController

A view controller for playing media content.

  • Playback state.

    See more

    Declaration

    Swift

    public enum State
  • The previous value of state. Default is .Idle.

    Declaration

    Swift

    public private(set) var previousState: State = .Idle
  • Current State of the player. Default is .Idle.

    Declaration

    Swift

    public private(set) var state: State = .Idle
  • The global player configuration object that is loaded by a player if none is passed for its initialization.

    Declaration

    Swift

    public static let globalConfig = MobilePlayerConfig()
  • The configuration object that was used to initialize the player, may point to the global player configuration object.

    Declaration

    Swift

    public let config: MobilePlayerConfig
  • A localized string that represents the video this controller manages. Setting a value will update the title label in the user interface if one exists.

    Declaration

    Swift

    public override var title: String?
  • Initializes a player with content given by contentURL. If provided, the overlay view controllers used to initialize the player should be different instances from each other.

    • parameters:
      • contentURL: URL of the content that will be used for playback.
      • config: Player configuration. Defaults to globalConfig.
      • prerollViewController: Pre-roll view controller. Defaults to nil.
      • pauseOverlayViewController: Pause overlay view controller. Defaults to nil.
      • postrollViewController: Post-roll view controller. Defaults to nil.

    Declaration

    Swift

    public init(
        contentURL: NSURL,
        config: MobilePlayerConfig = MobilePlayerViewController.globalConfig,
        prerollViewController: MobilePlayerOverlayViewController? = nil,
        pauseOverlayViewController: MobilePlayerOverlayViewController? = nil,
        postrollViewController: MobilePlayerOverlayViewController? = nil)

    Parameters

    contentURL

    URL of the content that will be used for playback.

    config

    Player configuration. Defaults to globalConfig.

    prerollViewController

    Pre-roll view controller. Defaults to nil.

    pauseOverlayViewController

    Pause overlay view controller. Defaults to nil.

    postrollViewController

    Post-roll view controller. Defaults to nil.

  • Returns a player initialized from data in a given unarchiver. globalConfig is used for configuration in this case. In most cases the other intializer should be used.

    • parameters:
      • coder: An unarchiver object.

    Declaration

    Swift

    public required init?(coder aDecoder: NSCoder)

    Parameters

    coder

    An unarchiver object.

  • Called after the controller'€™s view is loaded into memory.

    This method is called after the view controller has loaded its view hierarchy into memory. This method is called regardless of whether the view hierarchy was loaded from a nib file or created programmatically in the loadView method. You usually override this method to perform additional initialization on views that were loaded from nib files.

    If you override this method make sure you call super’s implementation.

    Declaration

    Swift

    public override func viewDidLoad()
  • Called to notify the view controller that its view is about to layout its subviews.

    When a view'€™s bounds change, the view adjusts the position of its subviews. Your view controller can override this method to make changes before the view lays out its subviews.

    The default implementation of this method sets the frame of the controls view.

    Declaration

    Swift

    public override func viewWillLayoutSubviews()
  • Notifies the view controller that its view is about to be added to a view hierarchy.

    If true, the view is being added to the window using an animation.

    The default implementation of this method hides the status bar.

    • parameters:
      • animated: If true, the view is being added to the window using an animation.

    Declaration

    Swift

    public override func viewWillAppear(animated: Bool)
  • Notifies the view controller that its view is about to be removed from a view hierarchy.

    If true, the disappearance of the view is being animated.

    The default implementation of this method stops playback and restores status bar appearance to how it was before the view appeared.

    • parameters:
      • animated: If true, the disappearance of the view is being animated.

    Declaration

    Swift

    public override func viewWillDisappear(animated: Bool)
  • Indicates whether content should begin playback automatically.

    The default value of this property is true. This property determines whether the playback of network-based content begins automatically when there is enough buffered data to ensure uninterrupted playback.

    Declaration

    Swift

    public var shouldAutoplay: Bool
  • Initiates playback of current content.

    Declaration

    Swift

    public func play()
  • Pauses playback of current content.

    Declaration

    Swift

    public func pause()
  • Ends playback of current content.

    Declaration

    Swift

    public func stop()
  • Makes playback content fit into player’s view.

    Declaration

    Swift

    public func fitVideo()
  • Makes playback content fill player’s view.

    Declaration

    Swift

    public func fillVideo()
  • Makes playback content switch between fill/fit modes when content area is double tapped. Overriding this method is recommended if you want to change this behavior.

    Declaration

    Swift

    public func handleContentDoubleTap()
  • An array of activity items that will be used for presenting a UIActivityViewController when the action button is pressed (if it exists). If content is playing, it is paused automatically at presentation and will continue after the controller is dismissed. Override showContentActions() if you want to change the button’s behavior.

    Declaration

    Swift

    public var activityItems: [AnyObject]?
  • Method that is called when a control interface button with identifier action is tapped. Presents a UIActivityViewController with activityItems set as its activity items. If content is playing, it is paused automatically at presentation and will continue after the controller is dismissed. Overriding this method is recommended if you want to change this behavior.

    Declaration

    Swift

    public func showContentActions()
  • Indicates if player controls are hidden. Setting its value will animate controls in or out.

    Declaration

    Swift

    public var controlsHidden: Bool
  • Returns the view associated with given player control element identifier.

    • parameters:
      • identifier: Element identifier.

    Declaration

    Swift

    public func getViewForElementWithIdentifier(identifier: String) -> UIView?

    Parameters

    identifier

    Element identifier.

    Return Value

    View or nil if element is not found.

  • Hides/shows controls when content area is tapped once. Overriding this method is recommended if you want to change this behavior.

    Declaration

    Swift

    public func handleContentTap()
  • The MobilePlayerOverlayViewController that will be presented on top of the player content at start. If a controller is set then content will not start playing automatically even if shouldAutoplay is true. The controller will dismiss if user presses the play button or play() is called.

    Declaration

    Swift

    public let prerollViewController: MobilePlayerOverlayViewController?
  • The MobilePlayerOverlayViewController that will be presented on top of the player content whenever playback is paused. Does not include pauses in playback due to buffering.

    Declaration

    Swift

    public let pauseOverlayViewController: MobilePlayerOverlayViewController?
  • The MobilePlayerOverlayViewController that will be presented on top of the player content when playback finishes.

    Declaration

    Swift

    public let postrollViewController: MobilePlayerOverlayViewController?
  • Presents given overlay view controller on top of the player content immediately, or at a given content time for a given duration. Both starting time and duration parameters should be provided to show a timed overlay.

    • parameters:
      • overlayViewController: The MobilePlayerOverlayViewController to be presented.
      • startingAtTime: Content time the overlay will be presented at.
      • forDuration: Added on top of startingAtTime to calculate the content time when overlay will be dismissed.

    Declaration

    Swift

    public func showOverlayViewController(
        overlayViewController: MobilePlayerOverlayViewController,
        startingAtTime presentationTime: NSTimeInterval? = nil,
        forDuration showDuration: NSTimeInterval? = nil)

    Parameters

    overlayViewController

    The MobilePlayerOverlayViewController to be presented.

    startingAtTime

    Content time the overlay will be presented at.

    forDuration

    Added on top of startingAtTime to calculate the content time when overlay will be dismissed.

  • Dismisses all currently presented overlay view controllers and clears any timed overlays.

    Declaration

    Swift

    public func clearOverlays()