Running an AVPlayerView in its own NSWindowController

62 Views Asked by At

I want to run an NSPlayer (with anNSPlayerView) in its own window where I can show demo and tutorial videos about my app. I started with an IBOutlet NSPlayerView. However, when I open the window containing the view ([self.demoWindowController showWindow:self];) the app crashes at that line with the error "[ setNilValueForKey]: could not set nil as the value for the key volume." The same error occurs if I try to add the NSPlayer to the window. Something like.

   `let playerView = AVPlayerView.init(frame: rect)
    let demoPlayer = AVPlayer.init(url: videoURL)
    playerView.player = demoPlayer
    self.window?.contentView?.addSubview(playerView)`

The app crashes with the same error at the ...addSubview code. Any feedback/help will be greatly appreciated

0

There are 0 best solutions below