Board index » delphi » TMediaPlayer with Delphi 5 (code snippet)

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

 

Re:TMediaPlayer with Delphi 5 (code snippet)


When I said a few bug fixes I meant from D4.03 to D5.  There were some changes.
One of which was wrong <g>.

I found 2 workarounds.  First is just leave the DeviceType to dtAutoSelect and
don't change it to dtWaveAudio.

The second is to change the code in MPlayer.pas and link the changed code
directly into your project.  The change should be before line 844.  Add

  If FElementName <> '' then
    FFlags := FFlags or mci_Open_Element;

I've logged this as a bug.

Quote
Serge Myrand wrote:

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Have you ever met a lady screaming angst potential?
Have you ever dreamed of romance no matter how experimental?
Have you ever felt an alien drifting back into your hometown?
Did you think you were buying safety when you bought that peice of ground?
             (Fish)
--

Other Threads