Hola Jusar.
Podés utilizar el componente
TMediaPlayer.
Por ejemplo:
Código:
...
#include<mplayer.hpp>
#define MP3_FILE "C:\\Users\\User\\Music\\Sound.mp3" /* ruta+nombre_archivo */
TMediaPlayer *mp = new TMediaPlayer(Form1);
void __fastcall TForm1::FormCreate(TObject *Sender)
{
mp->Parent = this;
mp->Visible = false;
mp->FileName = MP3_FILE;
mp->AutoRewind = true;
mp->AutoOpen = true;
mp->OnNotify = MediaPlayerNotify;
mp->Open();
mp->Play();
}
void __fastcall TForm1::MediaPlayerNotify(TObject *Sender)
{
if (mp->NotifyValue == nvSuccessful ){
mp->Play();
mp->Notify = true;
}
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
mp->Close();
delete mp;
}
También y más simple aún, pones el componente desde la paleta
System y ajustas sus propiedades desde el
Object Inspector.
Código:
void __fastcall TForm1::FormCreate(TObject *Sender)
{
MediaPlayer1->Open();
MediaPlayer1->Play();
}
void __fastcall TForm1::MediaPlayer1Notify(TObject *Sender)
{
if (MediaPlayer1->NotifyValue == nvSuccessful ){
MediaPlayer1->Play();
MediaPlayer1->Notify = true;
}
}
Un saludo.