10

I want to add a "subtitles" to a video played in an iPhone app. I don't want those subtitles encoded into the video itself - ideally I'd love to have a view showing the video (with pause, play, volume and such standard controls) together with a view displaying the text that changes together with movie time changing.

If I drawn that, it's something like this, movie with subtitle

So, basicly, I would need a way to get a method called when movie is playing, and then synchronize the text displayed on the label with the movie timing.

Anyone used a solution that was able to do it?

kender
  • 85,663
  • 26
  • 103
  • 145
  • Would the video be on the device (local) or streaming? If streaming you could encode on the fly using something like this: http://www.tuaw.com/2011/02/08/banana-tv-may-let-ios-devices-stream-video-to-the-mac/ from http://ericasadun.com/ she may have some code for encoding that you could use for local video playback as well. Are you going to use a .srt file for the subtitle(s)? – Phill Pafford Feb 09 '11 at 20:13
  • can we edit using the changing text in the video like movies in which names of actor comes one by one. – Imran Feb 13 '14 at 10:50

1 Answers1

9

I've recently done something that syncs graphics to times in an audio track. The way I did it was by using the currentPlaybackTime property of the MPMediaPlayback interface (which the MoviePlayer controller should also conform to). This returns the seconds elapsed in the media, in a double (typedef'ed as NSTimeInterval). The actual synchronisation in my app was not done in notifications, as I couldn't find any resembling a "tick", but instead I created a timer, calling a function queried the currentPlaybackTime, and updated the graphics based on this.

In terms of your implementation, I would assume you have some kind of system for associating label text (subtitles) with a particular time. You could then compare the text's time range with the time returned from currentPlaybackTime to find the correct text to display.

badgerr
  • 7,802
  • 2
  • 28
  • 43
  • can we edit using the changing text in the video like movies in which names of actor comes one by one. – Imran Feb 13 '14 at 10:50