Multimidia - tocando mp3 |
Top Previous Next |
//O componente TMediaPlayer pode reproduzir MP3 desde a versão 2 ou 3. Faça //algo tipo assim:
procedure TForm1.TocaMP3(Arquivo : string); begin MediaPlayer1.FileName := Arquivo; MediaPlayer1.Open; MediaPlayer1.Play; //a linha a seguir faz com que o TMediaPlayer fique tocando até chegar ao fim //do arquivo while MediaPlayer1.Position < MediaPlayer1.Length do Application.ProcessMessages; MediaPlayer1.Close; end;
// para implementação de um botão "Stop", adicione o seguinte: procedure TForm1.PararMusica; begin MediaPlayer1.Position := MediaPlayer1.Length; end;
//Apenas certifique-se de que o arquivo existe, foi aberto e, principalmente, //de FECHAR o TMediaPlayer (TMediaPlayer.Close) quando acabar de tocar. |