init(avPlayer:)
Creates a video player component from an AV player object.
Declaration
init(avPlayer: AVPlayer)Parameters
- avPlayer:
An Avplayer instance.
Discussion
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)