Is it possible to play a video on iPhone and have a subtitles synchronized with it show up?
Asked Answered
H

1

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?

Heartstrings answered 5/2, 2011 at 10:39 Comment(2)
Would the video be on the device (local) or streaming? If streaming you could encode on the fly using something like this: tuaw.com/2011/02/08/… from 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)?Palmation
can we edit using the changing text in the video like movies in which names of actor comes one by one.Artful
T
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.

Tanah answered 7/2, 2011 at 14:28 Comment(1)
can we edit using the changing text in the video like movies in which names of actor comes one by one.Artful

© 2022 - 2024 — McMap. All rights reserved.