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:
| unit Unit2;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, MPlayer, ShellApi;
type TForm1 = class(TForm) MediaPlayer1: TMediaPlayer; Button1: TButton; ListBox1: TListBox; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure ListBox1Click(Sender: TObject); Procedure WMDropFiles (Var aMsg: tMessage); message WM_DROPFILES; procedure MediaPlayer1Notify(Sender: TObject); private public Procedure AddToPlayList(s:string); procedure PlayFile(s:string); end;
var Form1: TForm1; playList: TStringList; CurrentSong: integer = -1; implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin DragAcceptFiles (Handle, True); playList := TStringList.Create; end;
procedure TForm1.FormDestroy(Sender: TObject); begin playList.Free; end;
procedure TForm1.Button1Click(Sender: TObject); begin mediaplayer1.FileName := 'C:\Dokumente und Einstellungen\Roderich Römhild\Eigene Dateien\Mein Spiel\VA-Fetenhits_(Fussball)-2CD-DE-2008-VOiCE\Live is life.mp3'; mediaplayer1.Open; mediaplayer1.play; end;
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(extractfilename(s)); 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;
procedure TForm1.MediaPlayer1Notify(Sender: TObject); begin if mediaplayer1.Position = mediaplayer1.Length then begin Listbox1.Selected[currentSong] := false; inc(CurrentSong); if CurrentSong < Playlist.Count then else CurrentSong := 0; PlayFile(CurrentSong); Listbox1.Selected[CurrentSong] := true; end; end;
end. |