Programming C# C++ (7) Delphi (619) .NET (2) Database (72) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280) Java (8) JavaScript (27) perl (9) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
|
Determine current CD track of TMediaPlayer
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:
How can I determine the current track of an audio CD played by TMediaPlayer?
Answer:
The following code will retrieve it from the TMediaPlayer component. If you want to display it on a form, you could put the code in a timer event. You need the unit MMSystem in your uses clause.  | |  | | unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MMSystem, MPlayer, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
procedure Timer1Timer(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.Timer1Timer(Sender: TObject);
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('Track %.2d', [Trk]);
Label2.caption := Format('Position %.2d:%.2d', [Min, Sec]);
end;
end;
end. | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|