iOS Developer Library — Pre-Release

Developer

SpriteKit Framework Reference SKVideoNode Class Reference

Options
Deployment Target:

On This Page
Language:

SKVideoNode

An SKVideoNode object is a node that uses the AV Foundation framework to display live video content. More...

Inheritance


Conforms To


Import Statement


Swift

import SpriteKit

Objective-C

@import SpriteKit;

Availability


Available in iOS 7.0 and later.
  • Creates and initializes a new video node using a video file stored in the app bundle.

    Declaration

    Swift

    init!(videoFileNamed videoFile: String!) -> SKVideoNode

    Objective-C

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

    Parameters

    videoFile

    The name of the video file.

    Return Value

    A new video node.

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Objective-C

    + (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.

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

    Declaration

    Swift

    init!(videoURL videoURL: NSURL!) -> SKVideoNode

    Objective-C

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

    Parameters

    videoURL

    The URL for the video to play.

    Return Value

    An initialized video node.

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Swift

    init!(videoFileNamed videoFile: String)

    Objective-C

    - (instancetype)initWithVideoFileNamed:(NSString *)videoFile

    Parameters

    videoFile

    The name of the video file.

    Return Value

    An initialized video node.

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • init(AVPlayer:) - initWithAVPlayer: Designated Initializer

    Initializes a video node using an existing AVPlayer object.

    Declaration

    Swift

    init!(AVPlayer player: AVPlayer!)

    Objective-C

    - (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.

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • init(videoURL:) - initWithVideoURL: Designated Initializer

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

    Declaration

    Swift

    init!(videoURL url: NSURL)

    Objective-C

    - (instancetype)initWithVideoURL:(NSURL *)url

    Parameters

    url

    The URL for the video to play.

    Return Value

    An initialized video node.

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Swift

    var anchorPoint: CGPoint

    Objective-C

    @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.

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • size size Property

    The dimensions of the video node, in points.

    Declaration

    Swift

    var size: CGSize

    Objective-C

    @property(nonatomic) CGSize size

    Discussion

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

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Starts video playback.

    Declaration

    Swift

    func play()

    Objective-C

    - (void)play

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Pauses video playback.

    Declaration

    Swift

    func pause()

    Objective-C

    - (void)pause

    Import Statement

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.