Click to See Complete Forum and Search --> : programming cd player


Harmen Gumster
May 19th, 1999, 02:25 AM
How to control the cdplayer with the AutoPC? We don't know what we are doing wrong.
we've got something like this:

//----------------------------------------------------------------------------------------------
// function: CSRApp::InitCdPlayer
//
//
//----------------------------------------------------------------------------------------------
BOOL
CSRApp::CD_InitPlayer()
{

AAM_SRCCAP asc;
//asc.m_dwID = AAM_SRC_CD;

if (AAM_GetSourceCap(AAM_SRC_CD/*BYID*/,&asc)== 0)// zero indicates succes, returns the capabilities of a specified audio source
{
g_hDev = CreateFile (asc.m_szDevDrv/*TEXT ("CDR1:")*/, GENERIC_READ,// creates a handle to the device
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, 0);
g_pApp->m_pSpeech->Speak(L"Create file succeeded, you hoe!",0);

if (INVALID_HANDLE_VALUE == g_hDev)
{
g_pApp->m_pSpeech->Speak(L"handel to device not succeeded!",0);
return( FALSE);
}
else
{
AAM_SelectSource(AAM_SRC_CD);// select the CD-Player
g_pApp->m_pSpeech->Speak(L"Select source CD player succeeded",0);
return TRUE;//FALSE;
CD_GetDiskInfo();
}
}
else
{
g_pApp->m_pSpeech->Speak(L"init cd player not succeeded!",0);
return FALSE;
}
}
//----------------------------------------------------------------------------------------------
// function: CSRApp::CD_GetDeviceStatus
//
//
//----------------------------------------------------------------------------------------------
BOOL
CSRApp::CD_GetDeviceStatus()
{
DWORD RetDataLen;
CDROM_DEVSTAT g_Status;
//g_Status.Reserved = 0;
//g_Status.DeviceStatus = 0x6D6E0000; // don't care
//g_Status.DeviceStatus = 0x00000000; // don't care


if (DeviceIoControl(g_hDev, CDROM_IOCTL_GET_DEVICE_STATUS,
&g_Status,
sizeof(g_Status),
NULL, 0,
&RetDataLen, NULL) == 0)
{
g_pApp->m_pSpeech->Speak(L"device status not succeeded!",0);
return( FALSE);
}
return (TRUE);
}



//----------------------------------------------------------------------------------------------
// function: CSRApp::cdGetDiskInfo
//
//
//----------------------------------------------------------------------------------------------

BOOL
CSRApp::CD_GetDiskInfo()
{
DWORD RetDataLen;
WORD wTrackIdx;


g_DiskValid = FALSE; // Assume no disk info
g_DiscInfo.Reserved = 0;
g_DiscInfo.ReqSession = 0;//0xff; // Do you want the last session?

if (DeviceIoControl(g_hDev, // This obtains the Table of
// Contents for the disk
CDROM_IOCTL_DISC_INFO,
&g_DiscInfo,
sizeof(g_DiscInfo),
NULL, 0,
&RetDataLen, NULL) == 0)
{
g_pApp->m_pSpeech->Speak(L"device I O control discinfo not succeeded!",0);
return( FALSE);
}

g_nTracks = (WORD)g_DiscInfo.LastTrack + 1 - g_DiscInfo.FirstTrack;

for( wTrackIdx = 0; wTrackIdx < g_nTracks; wTrackIdx++)
{
g_TrackInfo.TrackNumber = g_DiscInfo.FirstTrack + wTrackIdx;
g_TrackInfo.Reserved = 0;

if (DeviceIoControl(g_hDev,
CDROM_IOCTL_TRACK_INFO, // This obtains the track
// starting address and other
// data.
&g_TrackInfo,
sizeof(g_TrackInfo),
NULL, 0,
&RetDataLen, NULL) != NO_ERROR)
{
g_pApp->m_pSpeech->Speak(L"device I O control trackinfo not succeeded!",0);
return( FALSE);
}

g_Tracks[wTrackIdx].ti_msfaddr = g_TrackInfo.TrackAddr;
g_Tracks[wTrackIdx].ti_ctl = g_TrackInfo.TrackControl;
}
g_DiskValid = TRUE;// Assume no disk info
g_pApp->m_pSpeech->Speak(L"get info succeeded!",0);

return(TRUE);

}
//----------------------------------------------------------------------------------------------
// function: CSRApp::Start_CdPplayer
//
//
//----------------------------------------------------------------------------------------------

BOOL
CSRApp::CD_StartPlayer()
{




//LPVOID PlayInfo;


// if (g_bCdPlayer)
// {
//if (/*g_pApp->*/CD_GetDiskInfo())
//{
int iTrack = g_TrackNumber;
DWORD RetDataLen;
CDROM_AUDPLAY cdaudioplay;

cdaudioplay.Reserved = 0;
cdaudioplay.PlayRegion.Mode = CDROM_ADDR_MSF;
cdaudioplay.PlayFlags = 0;

// destination , source
memcpy(&cdaudioplay.PlayRegion.StartAddr , &g_Tracks[iTrack ].ti_msfaddr, sizeof(MSF_ADDR));
memcpy(&cdaudioplay.PlayRegion.EndAddr , &g_Tracks[iTrack+1].ti_msfaddr, sizeof(MSF_ADDR));


if(DeviceIoControl(/*g_pApp->*/g_hDev,CDROM_IOCTL_AUDIO_PLAY,
&cdaudioplay, sizeof(cdaudioplay),
NULL, 0, &RetDataLen, NULL) != NO_ERROR)
{
g_pApp->m_pSpeech->Speak(L"The CD player has not been started",0);
return FALSE;
}

g_pApp->m_pSpeech->Speak(L"The CD player has been started",0);
}
// }
else
{
g_pApp->m_pSpeech->Speak(L"CD player not initialized, or already playing",0);
return FALSE;
}
return TRUE;
}

Chainard Arnaud
May 19th, 1999, 03:26 AM
Hello,

Excuse me but i don"t undestand what you want what is AutoPC ?

=> Autorun ?
=> A thing to make the diferance betwen 2 CDs ?

Arnaud,
( Reply directely to my e-mail )
At : Terrasse.Gaetan@wanadoo.fr

A+

Ps : They're on this site a very good section call multimedia with sample of CD-Player and mixer.

Harmen Gumster
May 19th, 1999, 04:02 AM
the autopc is a car stereo, which is controlled by voice, working on a platform that has windowsce as operating system, and is made by clarion.
http://www.autopc.com and you can buy it through the webpage www.autoaccents.com
there is also a preview release AutoPC SDK from microsoft dowmloadable. It does not support Java, VB, MFC and ATL COM objects. since we do not have enough experience with API programming, we do not know what we are doing wrong.