Board index » delphi » playing an audio-cd from secondary cd-rom drive

playing an audio-cd from secondary cd-rom drive

Hi

How do I play an audio-cd from my secondary cd-rom drive?

When using tmediaplayer and setting the filename property to
'E:' I can play the audio-cd, but when changing it to 'F:'
the mediaplayer won't play the cd.

I have tried coding it myself by using mci commands, but it just
doesn't work, so I suspect that this simply cannot be done using mci.

Am I right ?

regards
Jimmy

 

Re:playing an audio-cd from secondary cd-rom drive


On Mon, 23 Jun 2003 11:44:21 +0200, "Jimmy Rasmussen"

Quote
<Jim...@get2net.dk> wrote:

>Hi

>How do I play an audio-cd from my secondary cd-rom drive?

>When using tmediaplayer and setting the filename property to
>'E:' I can play the audio-cd, but when changing it to 'F:'
>the mediaplayer won't play the cd.

>I have tried coding it myself by using mci commands, but it just
>doesn't work, so I suspect that this simply cannot be done using mci.

>Am I right ?

Look up MSDN Article ID: Q137579 (msdn CDs or MS)
It's in C, but hopefully it'll help. I haven't got two CD-drives in
one machine so can't test it.

--

Regards, Frank

Re:playing an audio-cd from secondary cd-rom drive


In article <3ef6cc01$0$15312$ba624...@nntp03.dk.telia.net>, "Jimmy Rasmussen"

Quote
<Jim...@get2net.dk> writes:
>I have tried coding it myself by using mci commands, but it just
>doesn't work, so I suspect that this simply cannot be done using mci.

I don't know what mci commands you used, however the following just opens the
tray, but you could put any mci commands in the "mci action commands" section.

The trick is to put the drive in OpenParms.lpStrElementName.

uses
  MMSystem;

type
  EMMException = class(Exception);

function GetMCIErrorStr(Error : DWord) : string;
{returns string description of mci error}
var
  ResultLen : integer;
begin
  Result := '';
  if Error = 0 then
    Exit;
  ResultLen := 200;
  SetLength(Result, ResultLen);
  mciGetErrorString(Error, PChar(Result), ResultLen);
  SetLength(Result, ResultLen);
end;

procedure TForm1.OpenCDDoor(Drive : string; DoorOpen : boolean);
{opens or closes CD door,
 may be used for any CD drive,
 must be used for other than default CD drive}
var
  OpenParms : TMCI_Open_Parms;
  ErrRet, DevId, dwFlags : DWord;
  {mci action command variables}
  SetParms : TMCI_Set_Parms;
begin
  try
    try
      {open device}
      FillChar(OpenParms, SizeOf(TMCI_Open_parms), #0);
      OpenParms.lpStrDeviceType := PChar(MCI_DEVTYPE_CD_AUDIO);
      OpenParms.lpStrElementName := PChar(Drive);
      dwFlags := MCI_OPEN_TYPE or MCI_OPEN_TYPE_ID or MCI_OPEN_ELEMENT
                 or MCI_WAIT or MCI_OPEN_SHAREABLE;
      ErrRet := mciSendCommand(0, MCI_OPEN, dwFlags, integer(@OpenParms));
      if ErrRet <> 0 then
        raise EMMException.Create('Open failed : ' + IntToStr(ErrRet) + #13 +
                                  GetMCIErrorStr(ErrRet));
      DevId := OpenParms.wDeviceId;
    // start of mci action commands
      {mci "Set" command - set appropriate flags}
      if DoorOpen then
        dwFlags := MCI_SET_DOOR_OPEN
      else
        dwFlags := MCI_SET_DOOR_CLOSED;
      ErrRet := mciSendCommand(DevId, MCI_SET, dwFlags, integer(@SetParms));
      if ErrRet <> 0 then
        raise EMMException.Create('Open failed : ' + IntToStr(ErrRet) + #13 +
                                  GetMCIErrorStr(ErrRet));
    // end mci commands
    finally
      {close device}
      mciSendCommand(DevId, MCI_CLOSE, MCI_WAIT, 0);
    end;
  except
    on E:EMMException do
      ShowMessage(E.Message);
  end;
end;

Alan Lloyd
alangll...@aol.com

Re:playing an audio-cd from secondary cd-rom drive


Quote
"Jimmy Rasmussen" <Jim...@get2net.dk> wrote:

|
|How do I play an audio-cd from my secondary cd-rom drive?

Simple answer - you don't.  You have received 2 answer on how to
control the drive, but there is one problem.  Normal playing of a CD
requires an audio connection from the drive to the sound card, and
there is usually only one (you could run a cable from the player
headphone jack to the sound card line-in and get audio this way).  The
secondary drive may spin, but no sound will reach the sound card.

It CAN be done.  If you can retrieve the raw data from the CD, convert
it to .wav-like data, and feed it to the sound card, it should work.
I understand there is an available player that uses this technique for
better audio quality, so it is possible.

Maybe someone can put you on the track for using this method.

Phil

Other Threads