Author: Tomas Rutkauskas
TMediaPlayer: What track am I on?
Answer:
Although writing multimedia applications using Delphi is a three-step process
(click, drag and drop!), some people still ask how to find out what track is
currently playing on the CD player. Just get that info, just drop a TMediaPlayer
component on the form, with all the properties correctly set and bound to the CD
player. Also, add "MMSystem" to the uses clause in the calling form. To complete,
create a TTimer and put the code below in its OnTimer event:
1 var2 Trk, Min, Sec: word;
3 begin4 with MediaPlayer1 do5 begin6 Trk := MCI_TMSF_TRACK(Position);
7 Min := MCI_TMSF_MINUTE(Position);
8 Sec := MCI_TMSF_SECOND(Position);
9 Label1.Caption := Format('%.2d', [Trk]);
10 Label2.Caption := Format('%.2d:%.2d', [Min, Sec]);
11 end;
12 end;