unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, CheckLst, MPlayer, ShellAPI, FileCtrl;
type
TForm3 =
class(TForm)
MediaPlayer1: TMediaPlayer;
Button1: TButton;
CheckListBox1: TCheckListBox;
MainMenu1: TMainMenu;
MainProgramm1: TMenuItem;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
sDir:
String;
sl2: TStringList;
// sl2 global verfügbar machen
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
idxOfCheckListBox:integer;
implementation
{$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(aPath + FindRec.
Name))
else
aResult.Add(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
for i:=0
to checklistbox1.Items.Count
do
begin
idxOfCheckListBox := CheckListBox1.ItemIndex;
MediaPlayer1.FileName:=sl2.Strings[idxOfCheckListBox];
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
end;
end.