Title: Media Player & Autorepeat Function
Question: how can I write an Autorepeat Function for Mediaplayer ?
Answer:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MPlayer;
type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
fAutoRepeat:Boolean;
procedure NotifyProc(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
MediaPlayer1.Notify := True;
MediaPlayer1.OnNotify := NotifyProc;
fAutorepeat := True;
end;
procedure TForm1.NotifyProc(Sender: TObject);
begin
With Sender As TMediaPlayer do begin
Case Mode of
mpStopped: IF fAutoRepeat
Then (Sender as tMediaplayer).play;
end;
//must set to true to enable next-time notification
Notify := True;
end;
end;
end.
Best Regards
Cesario