SKVideoNode Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/SpriteKit.framework
Availability
Available in iOS 7.0 and later.
Companion guide
Declared in
SKVideoNode.h

Overview

An SKVideoNode is a node that plays live video.

A video node can be instantiated using a video file in the bundle. Or, if you need more precise control over video playback, you can instantiate the video node using an AVPlayer object.

Tasks

Creating a Video Node

Setting the Video Node’s Visual Properties

Controlling Video Playback

Properties

anchorPoint

Defines the point in the sprite that corresponds to the node’s position.

@property(nonatomic) CGPoint anchorPoint
Discussion

You specify the anchor point using the unit coordinate space. The default value is (0.5,0.5), which means that the video is centered on the node’s position.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

size

The dimensions of the video node, in points.

@property(nonatomic) CGSize size
Discussion

The default value is the size of the video used to instantiate the node.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

Class Methods

videoNodeWithAVPlayer:

Creates and initializes a video node using an existing AVPlayer object.

+ (SKVideoNode *)videoNodeWithAVPlayer:(AVPlayer *)player
Parameters
player

A player object.

Return Value

A new video node.

Discussion

You can use the AVPlayer object to control playback.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

videoNodeWithVideoFileNamed:

Creates and initializes a new video node using a video file stored in the app bundle.

+ (SKVideoNode *)videoNodeWithVideoFileNamed:(NSString *)videoFile
Parameters
videoFile

The name of the video file.

Return Value

A new video node.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

videoNodeWithVideoURL:

Creates and initializes a video node using a URL that points to a video file.

+ (SKVideoNode *)videoNodeWithVideoURL:(NSURL *)videoURL
Parameters
videoURL

The URL for the video to play.

Return Value

An initialized video node.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

Instance Methods

initWithAVPlayer:

Initializes a video node using an existing AVPlayer object.

- (instancetype)initWithAVPlayer:(AVPlayer *)player
Parameters
player

A player object.

Return Value

An initialized video node.

Discussion

You can use the AVPlayer object to control playback.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

initWithVideoFileNamed:

Initializes a video node using a video file stored in the app bundle.

- (instancetype)initWithVideoFileNamed:(NSString *)videoFile
Parameters
videoFile

The name of the video file.

Return Value

An initialized video node.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

initWithVideoURL:

Initializes a video node using a URL that points to a video file.

- (instancetype)initWithVideoURL:(NSURL *)url
Parameters
url

The URL for the video to play.

Return Value

An initialized video node.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

pause

Pauses video playback.

- (void)pause
Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h

play

Starts video playback.

- (void)play
Availability
  • Available in iOS 7.0 and later.
Declared In
SKVideoNode.h