I am using UIImagePickerController to pick videos in a messaging app. These videos can then be played back on either an iOS app, Android app or Web app. I am using the code below.
let picker = UIImagePickerController()
picker.delegate = self
picker.mediaTypes = ["public.image", "public.movie"]
picker.videoQuality = UIImagePickerControllerQualityType.typeMedium
if #available(iOS 11.0, *) {
picker.videoExportPreset = AVVideoProfileLevelH264Baseline30
}
This works fine and the video message sends and plays back fine on iOS and web but when playing back in an Android VideoView I get a "Can't play this video" message. The video is definitely being saved to the Android device in the correct location as I can pull it from there using Android Device Monitor and see that it is definitely h264 but there is something about the file the Android VideoView doesn't like.
What am I missing to make these videos picked on iOS play on an Android device? I'd really rather not transcode them on a server because that will massively slow down the message delivery time.
Thanks for your help