I managed to make a Thread that plays the song, but only for 1 time. If I put a loop in it I have several errors, like the 1400.
It seems that the thread does not close when Form1 is closed, because the problem always happens when I try to close it.
I have only 2 units. 1 is Form1 and the other is the TMusica thread.
I've tried the Goto, While, Repeat, With. Nothing works, the song is called music.mp3. I use Delphi XE8
. How do I solve it?
TMusica Thread Call:
procedure TForm1.FormCreate(Sender: TObject);
var
Thread:TMusica;
begin
//Bloco de Códigos
Thread := TMusica.Create(False);
Thread.FreeOnTerminate := True;
Thread.Resume;
//Outros códigos...
end;
The TMusica Thread:
procedure TMusica.Execute;
begin
Form1.MediaPlayer1.FileName: = 'music.mp3';
Form1.MediaPlayer1.Open;
Form1.MediaPlayer1.Play;
end;