---
title: "init(avPlayer:)"
framework: realitykit
role: symbol
role_heading: Initializer
path: "realitykit/videoplayercomponent/init(avplayer:)"
---

# init(avPlayer:)

Creates a video player component from an AV player object.

## Declaration

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

## Parameters

- `avPlayer`: An doc://com.apple.documentation/documentation/AVFoundation/AVPlayer instance.

## Discussion

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: // 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)

## See Also

### Creating a video player component

- [init(videoRenderer:)](realitykit/videoplayercomponent/init(videorenderer:).md)
