Reputation: 28
I have used the AVPlayer to play the video. Here is the sample code.
player = AVPlayer(url: url)
playerViewController.player = player
player.play()
present(playerViewController, animated: false, completion: nil)
This code plays most of the videos just some videos sent from android or downloaded is not played. Although all the videos are in mp4 format. When i looked the videos info in my mac, I found out the following differences.
Videos not played by ios gallery, quick time and safari : Codecs: AAC, h.264 Color profile: (5-1-5)
(whatsapp is able to play this video)
Videos played by all iOS devices and platforms: Codecs: AAC, h.264 Color profile: (1-1-1)
Is there a way I can make all mp4 play in my iOS app.
Upvotes: 1
Views: 1807
Reputation: 25471
The simple answer to your question 'Is there a way I can make all mp4 play in my iOS app?' is unfortunately, no, and the same actually applies for Android also.
MP4 is a container format and it can contain many different types of video and audio encodings. Deviecs will typically only support a defined set, although it is typically quite a wide set and it is usually straightforward to choose a format that will work on both Android and iOS, if you have the luxury of being able to specify the format, or can transcode to your chosen format on the server side.
For Android the supported media types are here:
And for apple devices the best source (at the time of writing) is:
Upvotes: 1