It is currently Tue, 27 Jun 2017 19:30:37 GMT

Author Message
 Problems with MCI Seek

I am creating a simple VB application that plays CDs.  I am having
difficulty with the syntax of the MCI Seek command in VB.  Every time I
send it the command "Step", nothing happens, then I check the error message
and it says that the parameter is out of range.  Do any of you know why?

Frank Hoffman

 Sun, 26 Dec 1999 03:00:00 GMT   
   [ 1 post ] 

Similar Threads

1.MCI all sorts of problems!

I'm trying to write an app that uses mci to play wav files. 
The app needs to be able to switch between the various devices available, so if
there are two sound cards, I want to be able to dynamically switch between them.

Ok, so the first job is when I play a file, I want to select the device. I use
the following fragment:

memset(&wop, 0, sizeof(wop));
wop.lpstrDeviceType = "waveaudio";
if ((err = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE, (DWORD) (MCI_OPEN_PARMS *)
&wop)) == 0)
        MCI_WAVE_SET_PARMS wsp;
        memset(&wsp, 0, sizeof(wsp));
        wsp.wOutput = OutputDeviceId;
        if ((err = mciSendCommand(wop.wDeviceID, MCI_SET, MCI_WAVE_OUTPUT,
(DWORD) (MCI_OPEN_PARMS *) &wsp)) == 0)
                // then it's ok
                // then it's not ok
                char szBuf[500];
                mciGetErrorString(err, szBuf, sizeof(szBuf));

This MCI_SET command doesn't work. The OutputDeviceId is 2, which is an SB Live!
Wave Device, and I get this index from waveOutGetNumDevs() and
waveOutGetDevCaps(). The wop.wDeviceId is 1. The error message I get is "The MCI
device you are using does not support the specified command.". The error code is

Strangely, I downloaded the Mmmctrl VB sample from Microsoft, and within that
app, they do the same thing:

   rc = mciSendCommand(MMControl1.DeviceID, MCI_SET, MCI_WAVE_OUTPUT, parms)

I've checked the values - MMControl1.DeviceID is 1, same as in my code,
parms.wOutput is 2, same as in my code. Mysteriously it works in the VB app.

So, that's the first problem.
Second problem is when I come to play a second sound. I run this routine again,
and now the MCI_OPEN fails. I get the message "The device name is already being
used as an alias by this application.  Use a unique alias." Error code is 265,
which is MCIERR_DEVICE_OPEN. This is despite the fact that after playing the
first sound I call MCI_CLOSE on the device, which returns with no error.

So I modified the MCI_OPEN call to this:

char szAlias[50];
static int nAlias;
memset(&wop, 0, sizeof(wop));
wop.lpstrDeviceType = "waveaudio";
sprintf(szAlias, "alias%d", nAlias++);
wop.lpstrAlias = szAlias;
if ((err = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ALIAS , (DWORD)
(MCI_OPEN_PARMS *) &wop)) == 0)
... etc.

This now works, as long as every time I open it, I use a different alias string.
Intriguing. Obviously, I will eventually wrap round on my alias numbering, and
it just doesn't feel right. Something is using up resources somewhere, I'm sure.

If it is true that I can only use an alias once, how do I "re-use" these
aliases. I've tried calling MCI_OPEN with just the MCI_OPEN_ALIAS flag and
reusing an existing alias, but of course it fails with something like "this
requires a parameter, please supply one."

I've RTFM on MCI_OPEN. It has this very strange statement:

"If the MCI_OPEN_SHAREABLE flag is not specified when a device or file is
initially opened, all subsequent MCI_OPEN commands to the device or file will
fail. If the device or file is already open and this flag is not specified, the
call will fail even if the first open command specified MCI_OPEN_SHAREABLE.
Files opened for the MCISEQ.DRV and MCIWAVE.DRV devices are nonshareable."

I don't think that's the problem, I think this is intended to say "if you leave
a device open, then unless you specify MCI_OPEN_SHAREABLE then no-one else can
use it." That's not the case. I want to re-use it, and I close it after I've
played the sound.

Hoping someone has an idea, I'm stumped.


2. Problem with long running MCI control

3. MCI and path problems

4. MCI Stop/Pause Problems

5. Enumerating audio cd devices with mci problem

6. Problem changing TV tuner channel using MCI

7. Urgently need help with MCI spec. problem

8. Problem with MCI command for voice recording


10. mci problem

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software