AVPlayer doesn't work in app

Hello:

I am adding a video file to my MAC application. Before I create an archive, the video plays perfectly but when I run a copy of the archive, when I click on the button to start the video, NOTHING HAPPENS. No error message, Nothing. Any help to resolve this issue will be appreciated. Here is the code:

This code:

Code Block
@IBAction func AVSegue(_ sender: Any) {
let mainStoryboard = NSStoryboard(name: "Main", bundle: Bundle.main)
guard let avPlayerViewController = mainStoryboard.instantiateController (withIdentifier: "AVID") as?
AVPlayerViewController else {
print("Couldn't find viewController" )
        return
        }
presentAsModalWindow(avPlayerViewController)
  }


triggers the ViewController with the AV Player:

Code Block
import Cocoa
import AVKit
import AVFoundation
class AVPlayerViewController: NSViewController {
    @IBOutlet weak var playerView: AVPlayerView!
        override func viewDidLoad() { super.viewDidLoad()
            let url = URL(fileURLWithPath: Bundle.main.path(forResource:"SMRIntro",ofType: "mp4")!)
            let player = AVPlayer(url: url)
            playerView.player = player
            player.play()
          }
}

What are the values of AVPlayer.status and AVPlayer.error after you expect playback to have started?
The AVPlayer does not show at all. When I click on the link to trigger the segue to the AVPlayer Controller, I get absolutely no response. When I do the same with the run project in Xcode project the player loads and the video plays normally.
I discovered the reason for the video not playing: I did not include the AVKit.Framework in the link library.

Be sure to include the following in Link Library With Libraries(Build Phases)

AVKit.Framework

AVFoundation.Framework

That fixed it for me too can't believe it was so simple (spent hours - new here!). Thanks.

AVPlayer doesn't work in app
 
 
Q