unit WinSound_;
interface
uses
Windows, Messages, SysUtils,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MPlayer;
type
TForm1 = class(TForm)
MediaPlayerl: TMediaPlayer; // медиаплеер
Label1: TLabel;
ListBox1: TListBox;
Label2: TLabel;
procedure FormActivate(Sender: TObject);
procedure ListBoxlClick(Sender: TObject);
procedure MediaPlayerlClick(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
private
{ Private declarations } public
{ Public declarations } end;
const
SOUNDPATCH='с:\winnt\media\';
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
var
SearchRec: TSearchRec;
begin
Form1.MediaPlayer1.Play ;
if FindFirst(SOUNDPATCH+'*.wav', faAnyFile, SearchRec) =0
then
begin
Form1.ListBox1.Items.Add(SearchRec.Name) ;
while (FindNext(SearchRec) = 0) do
Form1.ListBox1.Items.Add(SearchRec.Name);
end;
end;
procedure TForm1.ListBoxlClick(Sender: TObject);
begin
Label2.Caption:=ListBox1.Items[ListBox1.itemlndex];
procedure TForm1.MediaPlayerlClick(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
begin
if (Button = btPlay)
and (Label2.Caption
<> '') then
begin
with MediaPlayerl
do begin
FileName:=SOUNDPATCH+Label2.Caption;
Open;
end;
end;
end;
end.