Author: Tomas Rutkauskas How can I write an Autorepeat Function for Mediaplayer ? Answer: 1 unit Unit1; 2 3 interface 4 5 uses 6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 7 MPlayer; 8 9 type 10 TForm1 = class(TForm) 11 MediaPlayer1: TMediaPlayer; 12 procedure FormCreate(Sender: TObject); 13 private 14 15 public 16 fAutoRepeat: Boolean; 17 procedure NotifyProc(Sender: TObject); 18 end; 19 20 var 21 Form1: TForm1; 22 23 implementation 24 25 {$R *.DFM} 26 27 procedure TForm1.FormCreate(Sender: TObject); 28 begin 29 MediaPlayer1.Notify := True; 30 MediaPlayer1.OnNotify := NotifyProc; 31 fAutorepeat := True; 32 end; 33 34 procedure TForm1.NotifyProc(Sender: TObject); 35 begin 36 with Sender as TMediaPlayer do 37 begin 38 case Mode of 39 mpStopped: if fAutoRepeat then 40 (Sender as tMediaplayer).play; 41 end; 42 //must set to true to enable next-time notification 43 Notify := True; 44 end; 45 end; 46 47 end.