Du hast 2 Fehler in Deinem Ausdruck:
1. erwartet mediaplayer1.FileName einen String:
RICHTIG: mediaplayer1.FileName:='augenzahl'+IntToStr(random(5)+1)+'.avi'.
2. musst Du verhindern, dass ein AVI-File mehrmals ausgewählt wird - es kann NUR 1x geöffnet werden!
Lösung:
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:
| procedure TForm1.FormActivate(Sender: TObject); var MP2,MP3,MP4,MP5 : Boolean; Label M2,M3,M4,M5;
begin randomize(); Mediaplayer1.FileName:='D:\BDS\clock'+IntToStr(random(6)+1)+'.avi'; MediaPlayer1.Open; Mediaplayer1.Play;
sleep(500); M2: MP2:=false; try Mediaplayer2.FileName:='D:\BDS\clock'+IntToStr(random(6)+1)+'.avi'; MediaPlayer2.Open; Mediaplayer2.Play; MP2:=true; except on EMCIDeviceError do; end; if MP2=false then Goto M2;
sleep(500); M3: MP3:=false; try Mediaplayer3.FileName:='D:\BDS\clock'+IntToStr(random(6)+1)+'.avi'; MediaPlayer3.Open; Mediaplayer3.Play; MP3:=true; except on EMCIDeviceError do ; end; if MP3=false then Goto M3;
sleep(500); M4: MP4:=false; try Mediaplayer4.FileName:='D:\BDS\clock'+IntToStr(random(6)+1)+'.avi'; MediaPlayer4.Open; Mediaplayer4.Play; MP4:=true; except on EMCIDeviceError do ; end; if MP4=false then Goto M4;
sleep(500); M5: MP5:=false; try Mediaplayer5.FileName:='D:\BDS\clock'+IntToStr(random(6)+1)+'.avi'; MediaPlayer5.Open; Mediaplayer5.Play; MP5:=true; except on EMCIDeviceError do ; end; if MP5=false then Goto M5;
end; |