Информатика. Программирование в Delphi
214
procedure GetFilePath(Path:string);
var
searhrec:TSearchRec;
r:integer;
begin
ms_count:=0;
SetLength(ms,ms_count);
if DirectoryExists(Path) then
begin
r:=FindFirst(path+'*.wav',faAnyFile,searhrec);
while r=0 do
begin
inc(ms_count);
SetLength(ms,ms_count);
ms[ms_count-1]:=Path+searhrec.Name;
Form1.ListBox1.Items.Add(searhrec.Name);
r:=FindNext(searhrec);
end;
FindClose(searhrec);
r:=FindFirst(path+'*.mp3',faAnyFile,searhrec);
while r=0 do
begin
inc(ms_count);
SetLength(ms,ms_count);
ms[ms_count-1]:=Path+searhrec.Name;
Form1.ListBox1.Items.Add(searhrec.Name);
r:=FindNext(searhrec);
end;
FindClose(searhrec);
end;
if ms_count<>0 then
begin
curr:=0;
Form1.ListBox1.ItemIndex:=curr;
Form1.MediaPlayer1.FileName:=ms[curr];
Form1.MediaPlayer1.Open;
Form1.Caption:=ExtractFileName(ms[curr]);
end
else
begin
Form1.ListBox1.Clear;
ms_count:=0;
SetLength(ms,ms_count);
Form1.Caption:='';