Unexpected errors when using AVPlayer in iOS 16

Hi, I'm trying to add a video to my first iOS app. From the tutorials I've read online, this seemed to be a simple process of creating a AVPlayer, providing a URL to the video file and using onAppear to start the video playing when the view is shown.

Below is a simplified version of the code I'm using in my app:

struct ContentView: View {
  let avPlayer = AVPlayer(url: Bundle.main.url(forResource: "Intro", withExtension: "mp4")!)
  var body: some View {
    VStack{
      VideoPlayer(player: avPlayer)
        .onAppear{
          avPlayer.play()
        }
    }
  }
}

When I run this code, the video plays but when it finishes playing I receive the following errors in the Xcode output window:

2023-01-27 11:56:39.530526+1100 TestVideo[29859:2475750] [api] -[CIImage initWithCVPixelBuffer:options:] failed because the buffer is nil. 2023-01-27 11:56:39.676462+1100 TestVideo[29859:2475835] [TextIdentificationService] Text LID dominant failure: lidInconclusive 2023-01-27 11:56:39.676822+1100 TestVideo[29859:2475835] [VisualTranslationService] Visual isTranslatable: NO; not offering translation: lidInconclusive 2023-01-27 11:56:40.569337+1100 TestVideo[29859:2476091] Metal API Validation Enabled

I have googled each of these error messages but have not been able to find any information explaining exactly what they mean or how to eliminate them.

I am using Xcode 14.2 and testing on iOS 16.2.

If anyone could please point me in the right direction of how to understand and eliminate these errors I'd really appreciate it. Thanks!

Post not yet marked as solved Up vote post of Bandit03 Down vote post of Bandit03
1.9k views

Replies

Hey Bandit03, Same problem here, it was working two days ago normal, and now the errors wont let VideoPlayer onAppear play correctly. did you find any fix ? thanks.

I am seeing this same error happening in my app. It doesn't happen every time, but at least every 4 to 6 times I watch a video. Does anyone have an idea of what is happening?

I had the same problem when using a .mp4, seems like it doesn't happen with .mov, don't know exactly why yet

Facing the same issue for a long time , no solution yet. Please let me know if anyone of you have got this fixed.