Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play MKV video from remote

I'm trying to play a remote MKV video in my iOS app but the video won't play.

I tried with AVKit/AVFoundation and MobilePlayer and it's working with a MP4 file.

Here's a sample of my code:

AVKit / AVFoundation

let videoURL = NSURL(string: url)! // http://localhost:4000/../file.mkv
playerView = AVPlayer(URL: videoURL)
playerViewController.player = playerView
self.presentViewController(playerViewController, animated: true) {
  self.playerViewController.player!.play()
}

MobilePlayer

let videoURL = NSURL(string: url)! // http://localhost:4000/../file.mkv
let playerVC = MobilePlayerViewController(contentURL: videoURL)
playerVC.title = videoURL.lastPathComponent
playerVC.activityItems = [videoURL]
self.presentViewController(playerVC, animated: true) { 
  playerVC.play()
}
like image 538
TheAbstractDev Avatar asked Aug 19 '16 18:08

TheAbstractDev


1 Answers

AVKit/AVFoundation don't support mkv video format. You could consider using another video framework such as VLCKit.

like image 62
Niklas Berglund Avatar answered Sep 18 '22 12:09

Niklas Berglund