AVPlayerLayer Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AVFoundation.framework |
| Availability | Available in iOS 4.0 and later. |
| Companion guide | |
| Declared in | AVPlayerLayer.h |
Overview
AVPlayerLayer is a subclass of CALayer to which an AVPlayer object can direct its visual output.
You can create a layer as illustrated in the following code fragment:
AVPlayer *player = <#A configured AVPlayer object#>; |
CALayer *superlayer = <#Get a CALayer#>; |
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; |
[superlayer addSublayer:playerLayer]; |
The videoGravity property defines how the video content is displayed within the player layer’s bounds rect.
The value for the contents key of a player layer is opaque and effectively read-only.
During playback, AVPlayer may compensate for temporal drift between its visual output and its audible output to one or more independently-clocked audio output devices by adjusting the timing of its associated player layers. The effects of these adjustments are usually very small; however, clients that wish to remain entirely unaffected by such adjustments may wish to place other layers for which timing is important into independently timed subtrees of their layer trees.
You can create arbitrary numbers of player layers with the same AVPlayer object. Only the most-recently-created player layer will actually display the video content on-screen.
Tasks
Miscellaneous
-
playerproperty -
+ playerLayerWithPlayer: -
readyForDisplayproperty -
videoGravityproperty
Properties
player
The player for which the player layer displays visual output.
Discussion
Availability
- Available in iOS 4.0 and later.
Declared In
AVPlayerLayer.hreadyForDisplay
Indicates whether the first video frame has been made ready for display for the current item of the associated player. (read-only)
Discussion
Use this property as an indicator of when best to show or animate-in a player layer into view. An player layer may be displayed, or made visible, while this property is NO, however the layer will not have any user-visible content until the value becomes YES.
This property remains NO for a player’s currentItem whose asset contains no enabled video tracks.
Availability
- Available in iOS 4.0 and later.
Declared In
AVPlayerLayer.hvideoGravity
Specifies how the video is displayed within a player layer’s bounds.
Discussion
Options are AVLayerVideoGravityResizeAspect, AVLayerVideoGravityResizeAspectFill, and AVLayerVideoGravityResize. The default is player.
This property is animatable.
Availability
- Available in iOS 4.0 and later.
See Also
-
bounds(CALayer)
Declared In
AVPlayerLayer.hClass Methods
playerLayerWithPlayer:
Returns a player layer to display the visual output of a specified player.
Parameters
- player
The player for which the player layer displays visual output.
Return Value
A player layer configured to display the visual output of player.
Discussion
Availability
- Available in iOS 4.0 and later.
Declared In
AVPlayerLayer.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-12-23)