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
|
var
B : integer;
procedure TForm1.btJouerClick(Sender: TObject);
begin
Lecteur;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if (Key <> chr(8)) and ((Key < '0') or (Key > '9')) then
begin
Key := chr(0); // Permet d'annuler la frappe de la touche
end;
end;
procedure TForm1.Lecteur;
begin
if RadioBtmont.Checked then
begin
MediaPlayer1.FileName := 'C:\Sons\MONTE.WAV';
MediaPlayer1.Open;
MediaPlayer1.Notify := true;
MediaPlayer1.OnNotify := NotifyProc;
B:= StrToInt(Edit1.Text);
MediaPlayer1.Play;
Arretautorise := true; // évite un bug si nous appuyons sur arrêter
// alors q'aucun son WAV n'a été lancé
end;
procedure TForm1.NotifyProc(Sender: TObject);
begin
with Sender as TMediaPlayer do
begin
if Mode = mpStopped
then begin
Dec(B);
if B > 0 then Play
end;
Notify := True
end
end;
procedure TForm1.btArreterClick(Sender: TObject);
begin
if Arretautorise then
begin
MediaPlayer1.Stop;
end;
end; |