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?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
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 theMPMoviePlayerController
view), with the current movie time. You should write a class which you can ask forsubtitleStringAtTimeInterval
: kind of thing (which keeps the subtitles in memory and makes subtitle fetching faster). Then update the subtitles at regular intervals (withNSTimer
or a background thread which sleeps for a short time interval between each subtitle update).No code needed... AFAIK the button automatically shows up if the soft-subs are encoded in the video.
See here: http://www.bitfield.se/isubtitle/on_iphone_ipod.html
If your media file has embedded captions MPMoviePlayerViewController will show a button to enable/disable captions. By default, captions are disabled and can not be activated programatically.
Instead, you could use AVPlayer with closedCaptionDisplayEnabled property. But only iOS 4+