iOS Reference Library Apple Developer
Search

AVCaptureVideoPreviewLayer Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 4.0 and later.
Declared in
AVCaptureVideoPreviewLayer.h

Overview

AVCaptureVideoPreviewLayer is a subclass of CALayer that allows you use to display video as it is being captured by an input device.

You use this preview layer in conjunction with an AV capture session, as illustrated in the following code fragment:

AVCaptureSession *captureSession = <#Get a capture session#>;
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
UIView *aView = <#The view in which to present the layer#>;
previewLayer.frame = aView.bounds; // Assume you want the preview layer to fill the view.
[aView.layer addSublayer:previewLayer];

Tasks

Creating a Session

Layer Configuration

Properties

For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.

automaticallyAdjustsMirroring

Indicates whether the layer display automatically adjusts mirroring.

@property(nonatomic) BOOL automaticallyAdjustsMirroring

Discussion

The default value is YES.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

mirrored

Indicates whether the layer display is mirrored.

@property(nonatomic, getter=isMirrored) BOOL mirrored

Discussion

To change the value of this property, the value of automaticallyAdjustsMirroring must be NO.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

mirroringSupported

Indicates whether the layer display supports mirroring. (read-only)

@property(nonatomic, readonly, getter=isMirroringSupported) BOOL mirroringSupported

Discussion

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

orientation

The layer’s orientation.

@property(nonatomic) AVCaptureVideoOrientation orientation

Discussion

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

orientationSupported

Indicates whether the layer display supports changing the orientation. (read-only)

@property(nonatomic, readonly, getter=isOrientationSupported) BOOL orientationSupported

Discussion

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

session

The capture session with which the layer is associated.

@property(nonatomic, retain) AVCaptureSession *session

Discussion

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

videoGravity

Indicates how the video is displayed within a player layer’s bounds rect.

@property(copy) NSString *videoGravity

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

Class Methods

layerWithSession:

Returns a preview layer initialized with a given capture session.

+ (id)layerWithSession:(AVCaptureSession *)session

Parameters
session

The capture session from which to derive the preview.

Return Value

A preview layer initialized to use session.

Discussion

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h

Instance Methods

initWithSession:

Initializes a preview layer with a given capture session.

- (id)initWithSession:(AVCaptureSession *)session

Parameters
session

The capture session from which to derive the preview.

Return Value

A preview layer initialized to use session.

Discussion

Availability
  • Available in iOS 4.0 and later.
Declared In
AVCaptureVideoPreviewLayer.h



Last updated: 2010-05-15

Did this document help you? Yes It's good, but... Not helpful...