Problems with getting video dimensions using the videoPlayerComponent

Why {videoPlayerComponent.playerScreenSize} cannot get right to the size of the video, print out the x and y is [0, 0], is this a BUG?

Hello,

Are you sure it is always zero? It won't have a size until it is actually present in the scene.

For example, running the following, it starts out as zero, but is then populated with it's proper size:

import SwiftUI
import RealityKit
import RealityKitContent
import AVKit

struct ImmersiveView: View {
    
    let entity = Entity()
    
    var body: some View {
        RealityView { content in
            
            let player = AVPlayer(url: Bundle.main.url(forResource: "example", withExtension: "mov")!)
            
            let videoPlayerComponent = VideoPlayerComponent(avPlayer: player)
            
            print(videoPlayerComponent.playerScreenSize)
            
            player.play()
            
            entity.components.set(videoPlayerComponent)
            entity.components.set(InputTargetComponent())
            entity.components.set(VideoPlayerDebugComponent())
            entity.name = "Video Player Entity"
            
            content.add(entity)
        }
    }
}

// Make sure you register this in your App init.
struct VideoPlayerDebugSystem: System {
    
    init(scene: RealityKit.Scene) {}
    
    func update(context: SceneUpdateContext) {
        let entities = context.entities(matching: .init(where: .has(VideoPlayerDebugComponent.self)), updatingSystemWhen: .rendering)
        
        for entity in entities {
            let videoPlayerComponent = entity.components[VideoPlayerComponent.self]!
            print(videoPlayerComponent.playerScreenSize)
        }
    }
}

// Make sure you register this in your App init.
struct VideoPlayerDebugComponent: Component {}
Problems with getting video dimensions using the videoPlayerComponent
 
 
Q