 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mario Sernicola Guest
|
Posted: Wed Apr 28, 2004 9:16 pm Post subject: TMEdiaPlayer: play audio files in repeat mode |
|
|
Hi,
There's a way using TMediaPlayer component, to play an audio files in
"repeat" mode? When the file ends to play, TMediaPlayer must repeat it
infinite times, until the program is closed or the utent kill it.
I open an audio file with this code:
//-------------------------
....
//play intro sound
if (FileExists(sound)) {
try {
mpPlayer->FileName = sound;
mpPlayer->Open();
mpPlayer->Play();
} catch (Exception &E) {}
}
//--------------------------
Thenks
Mario Sernicola
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Apr 28, 2004 9:44 pm Post subject: Re: TMEdiaPlayer: play audio files in repeat mode |
|
|
"Mario Sernicola" <mariosernicola.nospam (AT) libero (DOT) nospam.it> wrote
| Quote: | There's a way using TMediaPlayer component, to play
an audio files in "repeat" mode?
|
TMediaPlayer does not support that. You will have to either:
1) use a separate timer that checks the TMediaPlayer's Mode property
periodically and calls Play() when needed
2) don't use TMediaPlayer at all. If all you are trying to do is play a
sound file, then use the Win32 API PlaySound() function instead. It has a
SND_LOOP flag available that you can use to do what you are asking for.
Gambit
|
|
| Back to top |
|
 |
Mario Sernicola Guest
|
Posted: Thu Apr 29, 2004 3:10 pm Post subject: Re: TMEdiaPlayer: play audio files in repeat mode |
|
|
| Quote: | 1) use a separate timer that checks the TMediaPlayer's Mode property
periodically and calls Play() when needed
|
If I set an Interval property of 500 ms for a TTimer (for example), can this
disturb my application in efficiently terms?
| Quote: | 2) don't use TMediaPlayer at all. If all you are trying to do is play a
sound file, then use the Win32 API PlaySound() function instead. It has a
SND_LOOP flag available that you can use to do what you are asking for.
|
I need to play mp3 too and more sounds at the same time... (Actually I use 2
separated TMediaPlayer components) and I need to stop them in any instant.
Mario
|
|
| Back to top |
|
 |
Damon Chandler (TeamB) Guest
|
Posted: Sat May 01, 2004 4:57 am Post subject: Re: TMEdiaPlayer: play audio files in repeat mode |
|
|
Hi Mario,
You can use the TMediaPlayer::OnNotify event to determine when to
replay the sound...
void __fastcall TForm1::MediaPlayer1Notify(TObject *Sender)
{
if (MediaPlayer1->Mode == mpPlaying)
{
// (MediaPlayer1->AutoRewind == true)
MediaPlayer1->Play();
MediaPlayer1->Notify = true;
}
}
HTH,
--
Damon (TeamB)
Mario Sernicola wrote:
| Quote: | Hi,
There's a way using TMediaPlayer component, to play an audio files in
"repeat" mode? When the file ends to play, TMediaPlayer must repeat it
infinite times, until the program is closed or the utent kill it.
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat May 01, 2004 10:41 am Post subject: Re: TMEdiaPlayer: play audio files in repeat mode |
|
|
"Damon Chandler (TeamB)" <dmc27 (AT) cornell (DOT) edu> wrote
| Quote: | You can use the TMediaPlayer::OnNotify event
to determine when to replay the sound...
|
The trick is, however, that you need to set the Notify property to true
prior to calling Play(), and then you can't call anything else with Notify
set to true until the Play() finishes, otherwide the OnNotify event can get
messed up.
| Quote: | MediaPlayer1->Play();
MediaPlayer1->Notify = true;
|
You need to set Notify before calling Play(), not afterwards:
MediaPlayer1->Notify = true;
MediaPlayer1->Play();
If you set it afterwards, it won't have any effect on Play() at all, and the
OnNotify event won't be triggered.
Gambit
|
|
| Back to top |
|
 |
Damon Chandler (TeamB) Guest
|
Posted: Sat May 01, 2004 6:24 pm Post subject: Re: TMEdiaPlayer: play audio files in repeat mode |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: | The trick is, however, that you need to set the Notify
property to true prior to calling Play(),
[8<--- ]
If you set it afterwards, it won't have any effect on
Play() at all, and the OnNotify event won't be triggered.
|
For TMediaPlayer, MCI_NOTIFY is always used with MCI_PLAY, which means
that the Notify property is irrelevant to the Play() method; if an
OnNotify event handler is assigned, it will be called after playback is
completed.
As for the OnNotify event getting messed up, I've only had problems with
resuming after pausing, but there are ways to work around that.
Regards,
--
Damon (TeamB)
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|