I'm trying to play a video of type avi in an application created in xcode written in swift. The thing is all of the videos I have are in avi and I cannot afford time spent converting the videos right now. Is there a way to play the video in the provided Media player library? the code I wrote plays the audio of the video only:
func playVideo() {
let path = NSBundle.mainBundle().pathForResource(symbol, ofType:"avi")
let url = NSURL.fileURLWithPath(path!)
moviePlayer = MPMoviePlayerController(contentURL: url)
if let player = moviePlayer {
player.view.frame = self.view.bounds
player.prepareToPlay()
player.scalingMode = .AspectFill
self.view.addSubview(player.view)
}
or maybe there's a way to convert a video when the function is called?
I,
following the documentation of the MPMediaPlayer :
So, unfortunately, you can't use the MPMediaPlayer to read your avi video.
Thanks to VLC for iOs source code, you can re-use it to implement a custom player to read these files.