AVPlayer video preview issue iOS 14.0.1

351 views Asked by At

I am trying to play local and remote videos using AVPlayer and AVPlayerViewController but I am facing an issue. The player is playing the audio for video but not showing the preview.

It is working fine on all the iOS versions less than iOS 14.0.1.

Please help me on this issue

Here is the sample code

movieUrl = [NSURL fileURLWithPath:filePath];
AVPlayer *player = [AVPlayer playerWithURL:movieUrl];
theMoviPlayer = [[AVPlayerViewController alloc] init];
theMoviPlayer.player = player;
[self addSubview:theMoviPlayer.view];
theMoviPlayer.view.frame = self.bounds;
[theMoviPlayer.player play];

Look at this image for better understanding

1

There are 1 answers

0
Abdul Rehman On BEST ANSWER

I have found the actual reason of this issue. It seems that for certain non-standard encoding or fps, AVPlayer is not able to play video. I have exported the same video in correct encoding using some tool i.e, QuickTimePayer, and the video is playable now.

This issue is only producing on iOS 14.0.1, may be it is a bug/feature in AVPlayer in this update.

Conclusion: Always check your video encoding if your video is not playing or you are just hearing only audio without any video frames.