<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/VideoPlayerComponent/init(avPlayer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation20VideoPlayerComponentV02avD0ACSo8AVPlayerC_tcfc"
  },
  "title" : "init(avPlayer:)"
}
-->

# init(avPlayer:)

Creates a video player component from an AV player object.

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

## Parameters

`avPlayer`

An
<doc://com.apple.documentation/documentation/AVFoundation/AVPlayer>
instance.

## Discussion> Note: You can’t use the same `AVPlayer` object with more than one `VideoPlayerComponent`.

Here’s an example of setting up a video player component:

```swift
// Create an entity for display.
let videoEntity = Entity()

// Create an AV player with a URL.
let player = AVPlayer(url: "PLACEMENT_URL")

// Create a video player component with the AV player.
let videoPlayerComponent = VideoPlayerComponent(avPlayer: player)

// Attach the video player component to the entity.
videoEntity.components.set(videoPlayerComponent)
```

---

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)