Mac Developer Library

Developer

AVKit Framework Reference AVPlayerView Class Reference

Options
Deployment Target:

On This Page
Language:

AVPlayerView

The AVPlayerView class is a subclass of the NSView class that is used to to display and playback the visual content of an AVPlayer object using the standard playback controls.

This class provides an easy means to display AVFoundation media content (an AVPlayer instance specifically) in a view.

  • The AVPlayer instance that provides the media content for the view.

    Declaration

    Swift

    var player: AVPlayer?

    Objective-C

    @property AVPlayer *player

    Availability

    Available in OS X v10.9 and later.

  • Specifies an action pop-up button menu that is displayed by the player view.

    Declaration

    Swift

    var actionPopUpButtonMenu: NSMenu?

    Objective-C

    @property NSMenu *actionPopUpButtonMenu

    Discussion

    Clients can set this property in order to show an action pop-up button.

    Default is nil.

    Availability

    Available in OS X v10.9 and later.

  • A Boolean property that specifies if the current player view media can be trimmed. (read-only)

    Declaration

    Swift

    var canBeginTrimming: Bool { get }

    Objective-C

    @property(readonly) BOOL canBeginTrimming

    Availability

    Available in OS X v10.9 and later.

  • Sets the player view’s controls panel into trimming mode.

    Declaration

    Swift

    func beginTrimmingWithCompletionHandler(_ handler: ((AVPlayerViewTrimResult) -> Void)?)

    Objective-C

    - (void)beginTrimmingWithCompletionHandler:(void (^)(AVPlayerViewTrimResult result))handler

    Parameters

    handler

    The block is executed when the user selects either the Trim or the Cancel button in the trimming UI.

    The argument passed in is AVPlayerViewTrimOKButton if the user chose the Trim button or AVPlayerViewTrimCancelButton if the user chose the Cancel button.

    Discussion

    An example of the handler block is as follows:

    1. [playerView beginTrimmingWithCompletionHandler:^(NSInteger result) {
    2. if (result == AVPlayerViewTrimOKButton)
    3. {
    4. // user selected Trim button...
    5. }
    6. else
    7. {
    8. // user selected Cancel button...
    9. }
    10. }

    This method blocks until the user selects either the Trim or the Cancel button.

    Availability

    Available in OS X v10.9 and later.

  • Displays the provided chapter number and title momentarily in the player view.

    Declaration

    Swift

    func flashChapterNumber(_ chapterNumber: Int, chapterTitle chapterTitle: String)

    Objective-C

    - (void)flashChapterNumber:(NSUInteger)chapterNumber chapterTitle:(NSString *)chapterTitle

    Parameters

    chapterNumber

    The chapter number.

    chapterTitle

    The chapter title. This value is optional and can be nil.

    Availability

    Available in OS X v10.9 and later.

  • Constants that specify which, if any, controls are displayed for the player view. See controlsStyle for more information.

    Declaration

    Swift

    enum AVPlayerViewControlsStyle : Int { case None case Inline case Floating case Minimal static var Default: AVPlayerViewControlsStyle { get } }

    Objective-C

    enum { AVPlayerViewControlsStyleNone, AVPlayerViewControlsStyleInline, AVPlayerViewControlsStyleFloating, AVPlayerViewControlsStyleMinimal, AVPlayerViewControlsStyleDefault = AVPlayerViewControlsStyleInline }; typedef NSInteger AVPlayerViewControlsStyle;

    Constants

    • None

      AVPlayerViewControlsStyleNone

      No controls pane is associated with the view.

      Available in OS X v10.9 and later.

    • Inline

      AVPlayerViewControlsStyleInline

      The inline controls pane is associated with the view.

      Available in OS X v10.9 and later.

    • Floating

      AVPlayerViewControlsStyleFloating

      The floating controls pane is associated with the view.

      Available in OS X v10.9 and later.

    • Minimal

      AVPlayerViewControlsStyleMinimal

      The minimal controls pane is associated with the view.

      Available in OS X v10.9 and later.

    • Default

      AVPlayerViewControlsStyleDefault

      The default control style, which is AVPlayerViewControlsStyleInline.

      Available in OS X v10.9 and later.

    Import Statement

    Objective-C

    @import AVKit;

    Swift

    import AVKit

    Availability

    Available in OS X v10.9 and later.

  • Constants that specify what the user’s action was when trimming the media in a player view. See canBeginTrimming for more information.

    Declaration

    Swift

    enum AVPlayerViewTrimResult : Int { case OKButton case CancelButton }

    Objective-C

    enum { AVPlayerViewTrimOKButton, AVPlayerViewTrimCancelButton }; typedef NSInteger AVPlayerViewTrimResult;

    Constants

    • OKButton

      AVPlayerViewTrimOKButton

      The user selected the Trim button.

      Available in OS X v10.9 and later.

    • CancelButton

      AVPlayerViewTrimCancelButton

      The user selected the Cancel button.

      Available in OS X v10.9 and later.

    Import Statement

    Objective-C

    @import AVKit;

    Swift

    import AVKit

    Availability

    Available in OS X v10.9 and later.