unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, CheckLst, MPlayer, ShellAPI, FileCtrl, ExtCtrls;
type
TForm3 =
class(TForm)
MediaPlayer1: TMediaPlayer;
Button1: TButton;
CheckListBox1: TCheckListBox;
MainMenu1: TMainMenu;
MainProgramm1: TMenuItem;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Image1: TImage;
Button6: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure MainProgramm1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private-Deklarationen }
sDir:
String;
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
sl2: TStringList;
implementation
uses Unit1;
{$R *.dfm}
Procedure FindFiles (aPath, aFindMask:
String; aWithSub: Boolean; aResult: tStrings; removePath:Boolean);
Var
FindRec: tSearchRec;
Begin
If (aPath = '
')
or (aFindMask = '
')
or Not Assigned (aResult)
Then
Exit;
If aPath[Length (aPath)] <> '
\'
Then
aPath := aPath + '
\';
If FindFirst (aPath + aFindMask, faAnyFile, FindRec) = 0
Then
Repeat
If (FindRec.
Name <> '
.')
and (FindRec.
Name <> '
..')
Then
begin
if removePath
then
aResult.Add(ExtractFileName(FindRec.
Name))
{geändert}
else
aResult.Add(aPath + FindRec.
Name);
end;
Until FindNext (FindRec) <> 0;
FindClose (FindRec);
If Not aWithSub
Then
Exit;
If FindFirst (aPath + '
*.*', faAnyFile, FindRec) = 0
Then
Repeat
If (FindRec.
Name <> '
.')
and (FindRec.
Name <> '
..')
Then
If Boolean (FindRec.Attr
and faDirectory)
Then
FindFiles (aPath + FindRec.
Name, aFindMask, aWithSub, aResult, false);
Until FindNext (FindRec) <> 0;
FindClose (FindRec);
End;
procedure TForm3.Button1Click(Sender: TObject);
begin
if SelectDirectory('
Verzeichnis wählen', '
*:\', sDir)
then
begin
if DirectoryExists(sDir)
then
begin
FindFiles(sDir, '
*.mp3', True, CheckListBox1.Items, true);
FindFiles(sDir, '
*.mp3', true, sl2, false);
end;
end;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
sl2 := TStringList.Create;
end;
procedure TForm3.FormDestroy(Sender: TObject);
begin
sl2.Free;
end;
procedure TForm3.Button2Click(Sender: TObject);
Var i:integer;
begin
i:=0;
repeat
if checklistbox1.Checked[i]
then
begin
MediaPLayer1.FileName:=sl2.Strings[i];
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
i:=i+1;
until i=checklistbox1.Count-1
end;