Hi guys, i need some idea. I have a video file and an srt subtitle file.
The srt file looks like:
00:00:01,000 --> 00:00:05,000
- Some text
- Some text
- empty row -[/code]
Now i need to fill the label with the subtitle at the right moment. How should I do it? I have 3 arrays(start_sec as double, stop_sec as double, sub as string).
I tried to use a timer, get the current position of the player. Test if the position is between the start_sec(i) and stop_sec(i), in a loop.
Read the srt file in the
MoviePlayer.Position: The number of seconds from the start of the movie.
All you have to do is to display the SubTitle when its Start Display Position (*) = MoviePlayer.Position.
(*) Start Display Position: the value you wrote as: 00:00:01,000 --> 00:00:05,000.
I do not wrote Xojo code to achieve this goal, but I wrote some srt subtitle files long time ago.
Look at the
MoviePlayer Reference for more details.
Use Handbrake to add the srt file into the movie. Or do it using the terminal.
The problem is there are more than 1 row of text for each time, and i can place them as a “group” of text on the video. But i wanted to handle them seperately.
Then obviously you have to split the timing accordingly.
You split the file into “pages”.
After parsing those pages, I stored the data in an in-memory SQLite database. This made it easier to search for the correct titles by using the current playhead position of the mediaplayer, and look for the time-ranges.
By the way… I converted the timecode to miliseconds before storing it to the DB. This makes it easier to alter and calculate. When displaying I convert it back to “normal timecode”.