// Wave als Loop.


// Getestet mit D2010 unter Win7

type 
  TForm1 = class(TForm) 
    Button1: TButton; 
    Button2: TButton; 
    procedure Button1Click(Sender: TObject); 
    procedure Button2Click(Sender: TObject); 
  private 
    { Private-Deklarationen } 
  public 
    procedure WndProc(var M: TMessage); override; 
    procedure SoundPlay(const FileName, Alias: String); 
    procedure LoopClose; 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
{$R *.dfm} 
 
var 
  LoopSound: String; 
 
procedure TForm1.WndProc(var M: TMessage); 
begin 
  if M.Msg = MM_MCINOTIFY then 
  begin 
    mciSendString(PChar('seek ' + LoopSound + ' to start'), nil, 0, Handle); 
    mciSendString(PChar('play ' + LoopSound + ' notify'), nil, 0, Handle); 
  end; 
  inherited; 
end; 
 
procedure TForm1.SoundPlay(const FileName, Alias: String); 
begin 
  LoopSound := Alias; 
  mciSendString 
    (PChar('open ' + FileName + ' type waveaudio' + ' alias ' + Alias), 
    nil, 0, Handle); 
  mciSendString(PChar('play ' + Alias + ' FROM 0 notify'), nil, 0, Handle); 
end; 
 
procedure TForm1.LoopClose; 
begin 
  mciSendString(PChar('close ' + LoopSound), nil, 0, Handle); 
end; 
 
 
// Beispielaufrufe: 
 
// Loop starten 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  SoundPlay('D:\Test\Gewonnen.WAV', 'Gewinn'); 
end; 
 
// Loop stoppen 
procedure TForm1.Button2Click(Sender: TObject); 
begin 
  LoopClose; 
end;

 


 

Zugriffe seit 6.9.2001 auf Delphi-Ecke