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

TMediaPlayer: What track am I on?

By Zarko Gajic, About.com

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

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

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

Easy ways to connect two computers for networking purposes. 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.