<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKVideoNode/init(avPlayer:)-9ydbu",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKVideoNode(im)initWithAVPlayer:"
  },
  "title" : "init(avPlayer:)"
}
-->

# init(avPlayer:)

Initializes a video node using an existing <doc://com.apple.documentation/documentation/AVFoundation/AVPlayer> object.

```
init(avPlayer player: AVPlayer)
```

## Parameters

`player`

A player object.

## Return Value

An initialized video node.

## Discussion

You can use the <doc://com.apple.documentation/documentation/AVFoundation/AVPlayer> object to control playback.

Listing 1 shows, in Swift, how you can create a video node using the [`init(avPlayer:)`](/documentation/SpriteKit/SKVideoNode/init(avPlayer:)-9ydbu) initializer.

Listing 1. Creating a video node with an AV Player

```swift
var videoNode: SKVideoNode? = {
    guard let urlString = Bundle.main.path(forResource: "sample", ofType: "mov") else {
        return nil
    }
    
    let url = URL(fileURLWithPath: urlString)
    let item = AVPlayerItem(url: url)
    let player = AVPlayer(playerItem: item)
    
    return SKVideoNode(avPlayer: player)
}()
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)