从远程播放 MKV 视频

Play MKV video from remote

我正在尝试在我的 iOS 应用中播放远程 MKV 视频,但视频无法播放。

我试过 AVKit/AVFoundation 和 MobilePlayer,它正在处理 MP4 文件。

这是我的代码示例:

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()
}

手机播放器

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()
}

AVKit/AVFoundation不支持mkv视频格式。您可以考虑使用其他视频框架,例如 VLCKit.