1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, MPlayer, ComCtrls, ShellCtrls, StdCtrls, ImgList, Buttons, ExtCtrls, ShellApi;
type TForm1 = class(TForm) GroupBox1: TGroupBox; Edit1: TEdit; Button1: TButton; Button2: TButton; GroupBox2: TGroupBox; ListBox1: TListBox; ShellTreeView1: TShellTreeView; MediaPlayer1: TMediaPlayer; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; Button7: TButton; GroupBox3: TGroupBox; Image1: TImage; Button10: TButton; Button8: TButton; procedure Button4Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button10Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure ListBox1Click(Sender: TObject); private public Procedure AddToPlayList(s:string); procedure PlayFile(s:string); Procedure WMDropFiles (Var aMsg: tMessage); message WM_DROPFILES; end;
var Form1: TForm1; playList: TStringList; implementation
{$R *.dfm}
Procedure TForm1.WMDropFiles (Var aMsg: tMessage); Var Idx, Size, FileCount: Integer; Filename: pChar; Begin Inherited; FileCount := DragQueryFile (aMsg.WParam, $FFFFFFFF, nil, 255); For Idx := 0 To FileCount -1 Do Begin Size := DragQueryFile (aMsg.WParam, Idx, nil, 0) + 1; Filename := StrAlloc (Size); If DragQueryFile (aMsg.WParam, Idx, Filename, Size) = 1 Then else AddToPlayList (pChar (Filename)); StrDispose (Filename); End; DragFinish (aMsg.WParam); End;
Procedure TForm1.AddToPlayList(s:string); begin playList.Add(s); ListBox1.Items.Add(s); end;
procedure FindFiles(const Path: String; const Ext: array of String; Result: TStrings); procedure SearchFiles(const Path: String; const Ext: array of String; Result: TStrings); var SR: TSearchRec; I: Integer; begin if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then begin repeat if (SR.Name <> '.') and (SR.Name <> '..') then begin if (SR.Attr and faDirectory) = faDirectory then SearchFiles(IncludeTrailingPathDelimiter(Path + SR.Name), Ext, Result) else for I := Low(Ext) to High(Ext) do if SameText(Ext[I], ExtractFileExt(SR.Name)) then begin Result.Add(Path + SR.Name); Break; end; end; until FindNext(SR) <> 0; FindClose(SR); end; end;
begin Result.Clear; SearchFiles(IncludeTrailingPathDelimiter(Path), Ext, Result); end;
procedure TForm1.Button4Click(Sender: TObject); begin close; end;
procedure TForm1.Button1Click(Sender: TObject); begin edit1.Text:=ShellTreeView1.Path; end;
procedure TForm1.Button2Click(Sender: TObject); begin edit1.Text:=''; end;
procedure TForm1.Button8Click(Sender: TObject); var i:string; begin FindFiles(edit1.Text,['.mp3'], ListBox1.Items); end;
procedure TForm1.Button10Click(Sender: TObject); begin ListBox1.Items.clear; end;
procedure TForm1.Button3Click(Sender: TObject); var i:string; begin mediaplayer1.FileName := 'C:\Dokumente und Einstellungen\Peter Paul\Desktop\Abwärts\terrorbeat.mp3'; mediaplayer1.Open; mediaplayer1.play; end;
procedure TForm1.FormCreate(Sender: TObject); begin DragAcceptFiles (Handle, True); playList := TStringList.Create; end;
procedure TForm1.FormDestroy(Sender: TObject); begin playList.Free; end;
procedure TForm1.PlayFile(s:string); begin mediaplayer1.Close; mediaplayer1.FileName := s; mediaplayer1.Open; mediaplayer1.play; end;
procedure TForm1.ListBox1Click(Sender: TObject); var i : integer; begin for i := 0 to listbox1.Count - 1 do if listbox1.Selected[i] then break; if fileexists(Playlist.Strings[i]) then PlayFile(Playlist.Strings[i]); end;
end. |