8

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()
}
TrebledJ
  • 8,713
  • 7
  • 26
  • 48
TheAbstractDev
  • 139
  • 1
  • 10

1 Answers1

5

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

Niklas Berglund
  • 3,563
  • 4
  • 32
  • 32