Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TTimer in Delphi to display synced lyrics? 6

Status
Not open for further replies.

doctorjellybean

Programmer
May 5, 2003
145
There is a clever program called MiniLyrics, and I want to achieve the same effect in my multimedia application.

That is, when it plays a track, it loads the lyrics from a file and display it synchronized to the track. MiniLyrics uses timestamps in its file, e.g.

[00:07.79]Jennifer Juniper lives upon the hill,
[00:15.23]Jennifer Juniper, sitting very still.
[00:23.36]Is she sleeping ? I don't think so.
[00:26.55]Is she breathing ? Yes, very low.


Is it possible to achieve the same object with the TTimer component, and if yes, what is the best way?

Thank you.
 
Maybe I'm doing something wrong. If I use the above code in the LoadLyricFile function, it picks up the problem and displays the error dialog box. On clicking ok, the code proceeds into the Timer section and starts an endless loop of an access violation error.
 
You need the procedure to quit when you hit that part (the code was a generic example).

Replacing Exit with Halt(0); should get what you want.

 
It seems the only way I could get it to work the way I wanted it to, was to insert the error trapping code in the play track procedure:

Code:
try
LoadLyricFile(openedlyric);
LyricPos := 1;
mediaplayer1.Play;
Timer_TrackPlayer.Enabled:=true;
btn_stoptrack.SetFocus;
except
  On E: EConvertError do
    begin
      MediaPlayer1.Rewind;
mediaplayer1.Play;
btn_stoptrack.SetFocus;

    end;
end;
end;

This way the user can still play the audio without a valid lyric file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top