An object that displays the video content from a player object along with system-supplied playback controls.
SDKs
- iOS 8.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- AVKit
Declaration
class AVPlayerViewController : UIView Controller
Overview
Using AVPlayer
makes it easy for you to add media playback capabilities to your application matching the styling and features of the native system players. Since AVPlayer
is a system framework class, your playback applications automatically adopt the new aesthetics and features of future operating system updates without any additional work from you.
Important
Do not subclass AVPlayer
. Overriding this class’s methods is unsupported and results in undefined behavior.
Supporting AirPlay
AirPlay lets users play your video content on an Apple TV and stream audio content to third-party AirPlay speakers and receivers. AVPlayer
automatically supports AirPlay, but you need to perform some project and audio session configuration before it can be enabled in your application. See Configuring Audio Settings for iOS and tvOS in Media Playback Programming Guide for more on how to perform this configuration.
See AirPlay Overview for more information about the features and capabilities of AirPlay.
Adopting Picture in Picture Playback
Starting in iOS 9, you can use AVPlayer
to provide Picture in Picture (PiP) playback on supported iPad models. PiP playback lets users minimize your video player to a small floating window so they can perform other activities in the primary application or even in another application. This brings a new level of multitasking capabilities to the iPad allowing users to continue playback while performing other activities on their devices. To learn more about how to support PiP playback in your iPad applications, see AVKit for iOS in Media Playback Programming Guide.
Using AVPlayerViewController in tvOS
AVPlayer
in tvOS brings advanced Siri Remote control features to your application. This lets users easily play and navigate your content and access supporting features such as subtitles and alternate audio tracks. AVPlayer
also provides support for using Siri Remote voice commands such as “Skip ahead 15 seconds” and “What did she say?” to control playback of your content.
AVKit for tvOS extends the features of AVPlayer
and AVPlayer
to provide additional ways of navigating and presenting content.
External Metadata. If you use the
external
property to associate additional metadata with theMetadata AVPlayer
object presented in the player view controller, theItem AVPlayer
UI can display that information.View Controller Navigation Marker Groups. A group of navigation markers allows the user to jump between significant events in a media presentation. The most common form of navigation marker group is a chapter list, but you can also create additional or alternative means of navigation—for example, to allow the user to quickly jump between key moments in a recorded sporting event. The player view controller lets the user choose between multiple marker groups for navigating through the media content it presents.
Use the
AVNavigation
class to create and describe navigation markers, then use theMarkers Group navigation
property to associate marker groups with theMarker Groups AVPlayer
object presented in the player view controller.Item Interstitial Content. Some content might be unrelated to the main content presented in your player view controller, or have different presentation requirements. For example, you might not allow the user to skip over advertisements when scrubbing through the playback timeline, or require that the user not skip mandatory legal notices.
Use the
AVInterstitial
class to describe interstitial content, and theTime Range interstitial
property to associate those time ranges with theTime Ranges AVPlayer
object presented in the player view controller. Then, you can use the player view controller’sItem delegate
object to be notified when interstitial content plays, and change playback options such as therequires
property accordingly.Linear Playback Content Proposals. When presenting serialized content, such as a TV show, you often want to propose additional content for the user to watch when the current episode ends. Starting with tvOS 10, it’s easy to add this functionality to your app using AVKit content proposals.
Use the
AVContent
class to describe the proposed content, and set it as theProposal next
property of theContent Proposal AVPlayer
object presented in the player view controller. You can implement the methods of the player view controller’sItem delegate
object to prepare to present a content proposal and perform actions in response to a user accepting, rejecting, or deferring the proposal.
See AVKit for tvOS in Media Playback Programming Guide for more information on how to use these features.