Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value on an mp4 file I've added to project

I’m unable to figure out why I’m getting this "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value" error when the file is clearly in the project and is an mp4 file. I’ve imported the proper AVKit, etc. and still cannot figure this out

enter image description here

 @State var player = AVPlayer(url:  Bundle.main.url(forResource: "bump", withExtension: "mp4")!)
    
    var body: some View {
        VStack {
            VideoPlayer(player: player)
                .allowsHitTesting(false)
        }
        .padding()
    }

I’ve even replaced the player with the following code and have gotten the same result

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "bump", ofType: "mp4")!))

>Solution :

Double-check to make sure bump.mp4 was added into bundle resources.

Project -> Target -> Build Phases -> Copy Bundle Resources -> Tap (+)

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading