Class

AVPlayerView

AVPlayerView is an NSView subclass used to display the visual content of an AVPlayer object and present standard controls to manage its playback. Using AVPlayerView, you can easily build media players with the same core playback features of QuickTime Player.

Overview

The player view supports a variety of different controls styles, ranging from no controls at all to controls matching the look of QuickTime Player. This makes it easy for you to tailor the presentation to best match your use of the player view. Regardless of the selected controls style, the player view always supports a standard set of keyboard shortcuts to control playback:

  • The spacebar plays and pauses playback.

  • The right and left arrow keys step frame-by-frame through the video.

  • JKL Navigation:

    • The J key rewinds. You can press it multiple times to cycle through rewind speeds.

    • The K key stops playback.

    • The L key fast-forwards. You can press it multiple times to cycle through fast-forward speeds.

In addition to providing the core playback interface for your media applications, AVPlayerView also makes it easy to add trimming capabilities to your player. Invoking the player view’s beginTrimming(completionHandler:) method presents a trimming interface like that of QuickTime Player making it easy to trim the media to the desired time range.

AVPlayerView is built with modern applications in mind and automatically supports all of the standard modern macOS features, such a localization, state restoration, full-screen playback, high-resolution display, and accessibility.

Symbols

Media Source for Playback View

var player: AVPlayer?

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

User Interface Customization

var controlsStyle: AVPlayerViewControlsStyle

The player view’s controls style.

var showsFrameSteppingButtons: Bool

A Boolean property that determines if frame stepping buttons should be shown in the player view.

var showsSharingServiceButton: Bool

A Boolean property that determines if a sharing service button is displayed.

var showsFullScreenToggleButton: Bool

A Boolean property that determines if the full screen toggle button is displayed.

var contentOverlayView: NSView?

Use the content overlay view to add additional custom views between the video content and the controls.

var actionPopUpButtonMenu: NSMenu?

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

Video Presentation

var isReadyForDisplay: Bool

Boolean property indicating that the current player item’s first video frame has been made ready for display.

var videoBounds: NSRect

The current size and position of the video image as displayed within the player view's bounds.

var videoGravity: String

The videoGravity determines how the video is displayed within a player view’s bounds.

Trimming Playback Content

var canBeginTrimming: Bool

A Boolean property that specifies if the current player view’s media can be trimmed.

func beginTrimming(completionHandler: ((AVPlayerViewTrimResult) -> Void)? = nil)

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

Display Chapter and Title

func flashChapterNumber(Int, chapterTitle: String)

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

Constants

AVPlayerViewControlsStyle

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

AVPlayerViewTrimResult

Constants that specify what the user’s action was when trimming the media in a player view. See beginTrimming(completionHandler:) for more information.

Relationships

Inherits From

Conforms To