github地址:https://github.com/mhergon/MPMoviePlayerController-Subtitles
支持最新的swift3
使用非常簡單,加入視頻文件,加入字幕名字之后,就可以顯示.srt的字幕了,很酷
// Video file
let videoFile = Bundle.main.path(forResource: "trailer_720p", ofType: "mov")
// Subtitle file
let subtitleFile = Bundle.main.path(forResource: "trailer_720p", ofType: "srt")
let subtitleURL = URL(fileURLWithPath: subtitleFile!)
// Movie player
let moviePlayerView = MPMoviePlayerViewController(contentURL: URL(fileURLWithPath: videoFile!))
presentMoviePlayerViewControllerAnimated(moviePlayerView)
// Add subtitles
moviePlayerView?.moviePlayer.addSubtitles().open(file: subtitleURL)
moviePlayerView?.moviePlayer.addSubtitles().open(file: subtitleURL, encoding: String.Encoding.utf8)
// Change text properties
moviePlayerView?.moviePlayer.subtitleLabel?.textColor = UIColor.red
// Play
moviePlayerView?.moviePlayer.play()