Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display subtitles within MPMoviePlayerController

I built a custom video player, all buttons are working. I need to know what is the code that does the MPMoviePlayerController display subtitles when the video has that option. I did not find anywhere an example or someone who knew what code is behind this subtitle button. Where can I find this?

like image 627
user722056 Avatar asked Nov 21 '11 13:11

user722056


1 Answers

You will have to implement your own subtitle file parser. The .srt file format is quite simple, here is a discussion about how to parse it.

The more challenging bit is to then synchronize the subtitle display (probably just a UILabel placed on top of the MPMoviePlayerController view), with the current movie time. You should write a class which you can ask for subtitleStringAtTimeInterval: kind of thing (which keeps the subtitles in memory and makes subtitle fetching faster). Then update the subtitles at regular intervals (with NSTimer or a background thread which sleeps for a short time interval between each subtitle update).

like image 122
jbat100 Avatar answered Oct 27 '22 23:10

jbat100