1

Is there a way to check if a .mp4 file is in correct format to be played by the AVPlayer?

I got a "broken" .mp4 file which i received from our backend. When i load this up in the AVPlayer, the "status" KVO always returns readyToPlay true, while this .mp4 is in incorrect format.

 if (object as? AVPlayer == self.player) && (keyPath! == "status") {
        if self.player?.status == AVPlayerStatus.readyToPlay {
          //Always ready to play
        }
    }

How can i check if a .mp4 is in correct format to be played by the AVPlayer?

Emre Akman
  • 1,212
  • 3
  • 19
  • 25

1 Answers1

1

Here is how I determine whether or not a .mp4 is playable in my ObjC code:

    NSURL *url = [NSURL fileURLWithPath:item.playable.filename];
    AVAsset *asset = [AVAsset assetWithURL:url];
    if (asset.isPlayable) {
Chris Edgington
  • 1,208
  • 12
  • 11