1. Home
  2. Computing & Technology
  3. Delphi Programming

TMediaPlayer: What track am I on?

By , About.com Guide

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:

~~~~~~~~~~~~~~~~~~~~~~~~~
uses MMSystem;

var
  Trk, Min, Sec : word;
begin
  with MediaPlayer1 do
  begin
    Trk := MCI_TMSF_TRACK(Position) ;
    Min := MCI_TMSF_MINUTE(Position) ;
    Sec := MCI_TMSF_SECOND(Position) ;
    Label1.Caption := Format('%.2d',[Trk]) ;
    Label2.Caption := Format('%.2d:%.2d',[Min,Sec]) ;
  end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» TMemo printing
« Week number calculating

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2000 Delphi Tips
  7. TMediaPlayer: What track am I on?

©2009 About.com, a part of The New York Times Company.

All rights reserved.