TMediaPlayer with Delphi 5 (code snippet)
Good day,
Jeff, as you request here is a code snippet for the play button and
the MPlayerNotify event from my application. But as I wrote in my first
e-mail this code works find in Delphi 4. (I use my own buttons and
mPlayer.visible = False).
I have checked the code in the de{*word*81} and the play method is executed
but nothing appends even not an error message. When you talk about few
bugs fixed do you talk about Delphi 5 and if yes is there a patch
somewhere.
Note that AutoEnable, AutoOpen and AutoRewind are set to False
{ play the wave File }
procedure TFrmMain.BtnPlayClick(Sender: TObject);
var
nItem: SmallInt;
begin
// si protg par mot de passe, avise l'utilisateur d'enlever la
protection
if PassWordProtected then
begin
BtnPlay.Down := False;
Exit;
end;
if ((MPlayer.Mode = mpPlaying) or (MPlayer.Mode = mpPaused))then
begin
BtnPlay.Down := True;
Exit;
end;
nItem := LBoxMsg.ItemIndex;
if nItem = - 1 then
Exit;
MPlayer.FileName := Copy(LBoxMsg.Items[nItem], (Pos('|',
LBoxMsg.Items[nItem]) + 1),
(Length(LBoxMsg.Items[nItem]) - Pos('|',
LBoxMsg.Items[nItem])));
nLBoxMsgIndex := LBoxMsg.ItemIndex;
With MPlayer do
begin
DeviceType := dtWaveAudio;
// le programme reprend le contr?le sans attendre que le wave ait
termin
Wait := False;
// s'assure que le device est ferm
if mode = mpOpen then
Close;
// ouvre le device
Open;
// joue le wave
Play;
end;
end;
{ notification de l'tat du multimdia device }
procedure TFrmMain.MPlayerNotify(Sender: TObject);
begin
// remonte le bouton aprs que le wave ait jou
if MPlayer.Mode = mpStopped then
begin
MPlayer.FileName := '';
BtnPlay.Down := False;
MPlayer.Close;
end;
MPlayer.Notify := True;
end;
Thank you agin
Serge Myrand