🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
9 messages
9 total messages Started by Stefano Bonifazi Tue, 01 Nov 2005 22:18
Playing Audio CD
#85
Author: Stefano Bonifazi
Date: Tue, 01 Nov 2005 22:18
10 lines
1399 bytes
Hi all :-)
 I need to play audio-cds from within my application.
The problem is that both TMediaPlayer and mci APIs seem to open always a 
"default" CD-ROM drive, that is I cannot set the CD-ROM drive in which the 
Audio cd is :-(
I'd need seek capabilities into the played track too
Is there anybody who can tell me how to do or can suggest a good FREE 
component/class to use?
Thank You very much in advance!
Stefano B. 
Re: Playing Audio CD
#86
Author: Remy Lebeau (TeamB)
Date: Tue, 01 Nov 2005 23:28
34 lines
2442 bytes
"Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
news:4367e9aa@newsgroups.borland.com...

>  I need to play audio-cds from within my application.  The problem
> is that both TMediaPlayer and mci APIs seem to open always a
> "default" CD-ROM drive, that is I cannot set the CD-ROM drive
> in which the Audio cd is :-(

TMediaPlayer does not support what you are looking for.

The MCI API, on the other hand, has an MCI_OPEN_TYPE_ID flag available for
the MCI_OPEN command.  That flag will allow you to specify the index of the
specific CD-ROM drive that you want to use.  You can use the MCI_SYSINFO
command to determine how many CD-ROM drives are available to MCI.  If
successful, the MCI_OPEN command returns the ID of the device, which you can
then use to send other commands to that same device.

> I'd need seek capabilities into the played track too

There is an MCI_SEEK command available for that.  Make sure to use the
MCI_SET command after opening the CD-ROM drive to set the device's time
format to MCI_FORMAT_TMSF (track/minute/second/frame).

You can use the MCI_MAKE_TMSF() macro when specifying time stamps to the
MCI_PLAY and MCI_SEEK commands.  Use the MCI_TMSF_TRACK(),
MCI_TMSF_MINUTE(), MCI_TMSF_SECOND(), and MCI_TMSF_FRAME() macros when
retreiving the individual values from time stamps that you obtain.

You can use the MCI_STATUS command to query information about the individual
tracks, such as their lengths.


Gambit
Re: Playing Audio CD
#87
Author: Stefano Bonifazi
Date: Wed, 02 Nov 2005 09:04
49 lines
2899 bytes
GREAT Mr. Gambit,
 I didn't know You are an expert of mutlimedia developing too ... Is there 
anything You can't do with BCB? :-)
I'll try what you suggest right now :)
Thank You very much again,
Best regards,
Stefano B.

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> ha scritto nel messaggio 
news:4367fa1f@newsgroups.borland.com...
>
> "Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
> news:4367e9aa@newsgroups.borland.com...
>
>>  I need to play audio-cds from within my application.  The problem
>> is that both TMediaPlayer and mci APIs seem to open always a
>> "default" CD-ROM drive, that is I cannot set the CD-ROM drive
>> in which the Audio cd is :-(
>
> TMediaPlayer does not support what you are looking for.
>
> The MCI API, on the other hand, has an MCI_OPEN_TYPE_ID flag available for
> the MCI_OPEN command.  That flag will allow you to specify the index of 
> the
> specific CD-ROM drive that you want to use.  You can use the MCI_SYSINFO
> command to determine how many CD-ROM drives are available to MCI.  If
> successful, the MCI_OPEN command returns the ID of the device, which you 
> can
> then use to send other commands to that same device.
>
>> I'd need seek capabilities into the played track too
>
> There is an MCI_SEEK command available for that.  Make sure to use the
> MCI_SET command after opening the CD-ROM drive to set the device's time
> format to MCI_FORMAT_TMSF (track/minute/second/frame).
>
> You can use the MCI_MAKE_TMSF() macro when specifying time stamps to the
> MCI_PLAY and MCI_SEEK commands.  Use the MCI_TMSF_TRACK(),
> MCI_TMSF_MINUTE(), MCI_TMSF_SECOND(), and MCI_TMSF_FRAME() macros when
> retreiving the individual values from time stamps that you obtain.
>
> You can use the MCI_STATUS command to query information about the 
> individual
> tracks, such as their lengths.
>
>
> Gambit
>
> 
Re: Playing Audio CD
#88
Author: Remy Lebeau (TeamB)
Date: Wed, 02 Nov 2005 09:06
11 lines
1288 bytes
"Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
news:436880f8@newsgroups.borland.com...

>  I didn't know You are an expert of mutlimedia developing too ...

I'm not.  But I do know how to read documentation ;-)  Everything you asked
for is in the Win32 Multimedia API documention.


Gambit
Re: Playing Audio CD
#89
Author: Stefano Bonifazi
Date: Wed, 02 Nov 2005 11:21
70 lines
3674 bytes
Sorry Mr. Gambit :( I really can't manage to get anything :(
By using the following code:
 MCI_SYSINFO_PARMS mcisysinfo;
 char Buffer[256];
 ZeroMemory(&mcisysinfo,sizeof(MCI_SYSINFO_PARMS));
 mcisysinfo.lpstrReturn=Buffer;
 mcisysinfo.dwRetSize=256;
 mcisysinfo.wDeviceType=MCI_DEVTYPE_CD_AUDIO;
 MCIERROR 
errcode=mciSendCommand(NULL,MCI_SYSINFO,MCI_SYSINFO_QUANTITY,(DWORD)&mcisysinfo);
 if(errcode==0)
 {
  RichEdit1->Lines->Add("Number of CD_ROM: "+IntToStr(Buffer));
 }
 else
 {
  mciGetErrorString(errcode,Buffer,256);
  RichEdit1->Lines->Add(AnsiString(Buffer));
 }

I get "Number of CD_ROM:  1" while I have 3 CDRoms (2 physique and one 
virtual) in my (WInXP Pro) system.
If I try to get the name by MCI_SYSINFO_NAME i get "cdaudio" and not 
something like "Plextor DVDR ..." :(
 Please Can You be so kind to write 2 lines of code showing how to get a 
list of my CD-Drives and how to open a selected one?
Thank You very much in advance,
Stefano B.

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> ha scritto nel messaggio 
news:4367fa1f@newsgroups.borland.com...
>
> "Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
> news:4367e9aa@newsgroups.borland.com...
>
>>  I need to play audio-cds from within my application.  The problem
>> is that both TMediaPlayer and mci APIs seem to open always a
>> "default" CD-ROM drive, that is I cannot set the CD-ROM drive
>> in which the Audio cd is :-(
>
> TMediaPlayer does not support what you are looking for.
>
> The MCI API, on the other hand, has an MCI_OPEN_TYPE_ID flag available for
> the MCI_OPEN command.  That flag will allow you to specify the index of 
> the
> specific CD-ROM drive that you want to use.  You can use the MCI_SYSINFO
> command to determine how many CD-ROM drives are available to MCI.  If
> successful, the MCI_OPEN command returns the ID of the device, which you 
> can
> then use to send other commands to that same device.
>
>> I'd need seek capabilities into the played track too
>
> There is an MCI_SEEK command available for that.  Make sure to use the
> MCI_SET command after opening the CD-ROM drive to set the device's time
> format to MCI_FORMAT_TMSF (track/minute/second/frame).
>
> You can use the MCI_MAKE_TMSF() macro when specifying time stamps to the
> MCI_PLAY and MCI_SEEK commands.  Use the MCI_TMSF_TRACK(),
> MCI_TMSF_MINUTE(), MCI_TMSF_SECOND(), and MCI_TMSF_FRAME() macros when
> retreiving the individual values from time stamps that you obtain.
>
> You can use the MCI_STATUS command to query information about the 
> individual
> tracks, such as their lengths.
>
>
> Gambit
>
> 
Re: Playing Audio CD
#91
Author: Remy Lebeau (TeamB)
Date: Wed, 02 Nov 2005 20:08
62 lines
3039 bytes
"Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
news:4368a145@newsgroups.borland.com...

>  mcisysinfo.wDeviceType=MCI_DEVTYPE_CD_AUDIO;
>  MCIERROR
>
errcode=mciSendCommand(NULL,MCI_SYSINFO,MCI_SYSINFO_QUANTITY,(DWORD)&mcisysi
nfo);

Try specifying MCI_DEVTYPE_CD_AUDIO instead of NULL as the IDDevice
parameter of mciSendCommand():

    MCI_SYSINFO_PARMS params = {0};
    char Buffer[256] = {0};
    params.lpstrReturn = Buffer;
    params.dwRetSize = 256;
    params.wDeviceType = MCI_DEVTYPE_CD_AUDIO;

    MCIERROR errcode = mciSendCommand(MCI_DEVTYPE_CD_AUDIO, MCI_SYSINFO,
MCI_SYSINFO_QUANTITY, (DWORD)&params);

If that doesn't work, then you will just have to enumerate the drive letters
manually by using the GetLogicalDriveStrings() and GetDriveType() functions:

    char DriveLetters[108] = {0};
    if( GetLogicalDriveStrings(sizeof(DriveLetters), DriveLetters) )
    {
        char *Drive = DriveLetters;
        while( *Drive != '\0' )
        {
            if( GetDeviceType(Drive) == DRIVE_CDROM )
                // use Drive as needed...
            Drive += 4;
        }
    }

When opening a device, you can open a specific drive letter without knowing
its index in the MCI table by specifying the drive letter in the
lpstrElementName member of the MCI_OPEN_PARMS structure:

    MCI_OPEN_PARMS params = {0};
    params.lpstrDeviceType = (LPSTR) MAKELONG(MCI_DEVTYPE_CD_AUDIO, 0);
    params.lpstrElementName = "X:";

    errcode = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID |
MCI_OPEN_ELEMENT, (DWORD)&params);

You can then send commands to the device ID that is returned.

Alternatively, you can use mciSendString() instead of mciSendCommand(),
using the "open" string:

    char Buffer[256];
    errcode = mciSendString("open X: type cdaudio alias MyCD", Buffer, 256,
NULL);

You can then send commands to the opened device using the "MyCD" alias (you
can name the alias whatever you want).


Gambit
Re: Playing Audio CD
#90
Author: Remy Lebeau (TeamB)
Date: Wed, 02 Nov 2005 20:09
12 lines
1271 bytes
"Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
news:4368a145@newsgroups.borland.com...

> If I try to get the name by MCI_SYSINFO_NAME i get "cdaudio"
> and not something like "Plextor DVDR ..." :(

After you determine the drive letter of your CD-ROM drives, try calling
GetVolumeInformation() on each one.


Gambit
Re: Playing Audio CD
#99
Author: Stefano Bonifazi
Date: Sun, 06 Nov 2005 11:55
88 lines
4179 bytes
Hi Mr. Lebeau,
 Sorry for the late I answer, but my studies keep me very busy :-(
You're great, guess what: I had posted other help messages for this subject 
in microsoft and I bet who would answer first with the right tip of 
course...
Guess who won :-)
Maybe you are not an expert of multimedia but according to me you are more 
prepared than many MS gurus of that subject, and of course  more kind ... I 
think their way to help only pass through a payment :-(
 Ok I already wrote a component to control CD-Audio, it's only a temporary 
version, but if you need it ask me, I have no a web page and I think BCB 
download site should be only for well working code :-) mine are only student 
tests :-)
THANK YOU VERY MUCH for all your help,
Stefano B.


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> ha scritto nel messaggio 
news:43691cc2$1@newsgroups.borland.com...
>
> "Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
> news:4368a145@newsgroups.borland.com...
>
>>  mcisysinfo.wDeviceType=MCI_DEVTYPE_CD_AUDIO;
>>  MCIERROR
>>
> errcode=mciSendCommand(NULL,MCI_SYSINFO,MCI_SYSINFO_QUANTITY,(DWORD)&mcisysi
> nfo);
>
> Try specifying MCI_DEVTYPE_CD_AUDIO instead of NULL as the IDDevice
> parameter of mciSendCommand():
>
>    MCI_SYSINFO_PARMS params = {0};
>    char Buffer[256] = {0};
>    params.lpstrReturn = Buffer;
>    params.dwRetSize = 256;
>    params.wDeviceType = MCI_DEVTYPE_CD_AUDIO;
>
>    MCIERROR errcode = mciSendCommand(MCI_DEVTYPE_CD_AUDIO, MCI_SYSINFO,
> MCI_SYSINFO_QUANTITY, (DWORD)&params);
>
> If that doesn't work, then you will just have to enumerate the drive 
> letters
> manually by using the GetLogicalDriveStrings() and GetDriveType() 
> functions:
>
>    char DriveLetters[108] = {0};
>    if( GetLogicalDriveStrings(sizeof(DriveLetters), DriveLetters) )
>    {
>        char *Drive = DriveLetters;
>        while( *Drive != '\0' )
>        {
>            if( GetDeviceType(Drive) == DRIVE_CDROM )
>                // use Drive as needed...
>            Drive += 4;
>        }
>    }
>
> When opening a device, you can open a specific drive letter without 
> knowing
> its index in the MCI table by specifying the drive letter in the
> lpstrElementName member of the MCI_OPEN_PARMS structure:
>
>    MCI_OPEN_PARMS params = {0};
>    params.lpstrDeviceType = (LPSTR) MAKELONG(MCI_DEVTYPE_CD_AUDIO, 0);
>    params.lpstrElementName = "X:";
>
>    errcode = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID 
> |
> MCI_OPEN_ELEMENT, (DWORD)&params);
>
> You can then send commands to the device ID that is returned.
>
> Alternatively, you can use mciSendString() instead of mciSendCommand(),
> using the "open" string:
>
>    char Buffer[256];
>    errcode = mciSendString("open X: type cdaudio alias MyCD", Buffer, 256,
> NULL);
>
> You can then send commands to the opened device using the "MyCD" alias 
> (you
> can name the alias whatever you want).
>
>
> Gambit
>
> 
Re: Playing Audio CD
#101
Author: Mark Jacobs
Date: Fri, 11 Nov 2005 14:36
16 lines
1628 bytes
Stefano Bonifazi wrote:
> Hi all :-)
>  I need to play audio-cds from within my application.
> The problem is that both TMediaPlayer and mci APIs seem to open always a 
> "default" CD-ROM drive, that is I cannot set the CD-ROM drive in which the 
> Audio cd is :-(
> I'd need seek capabilities into the played track too
> Is there anybody who can tell me how to do or can suggest a good FREE 
> component/class to use?

I used TMediaPlayer to build my free CD/Media player (with FreeDB track title lookup and 
loads of other features) called MJPlayer at http://www.jacobsm.com/mjsoft.htm#mjplyr

-- 
Mark Jacobs
http://www.dkcomputing.co.uk
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads