如何用mciSendString循环播放一个wav文件?我的程序可以播放一次wav文件,代码:
char buf[256];
mciSendString("play Close.wav", buf, strlen(buf),NULL); 我想循环播放一个文件,代码:
char buf[256];
mciSendString("play Close.wav repeat", buf, strlen(buf),NULL);
不能播放声音,返回的错误号为259,mciGetErrorString查询错误提示,返回空字符串。
错在哪里?会不会是我的系统有问题?

解决方案 »

  1.   

    请看这个:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_open.aspMSDN里面这段话是什么意思:
    The following command opens the "mysound" device:open new type waveaudio alias mysound buffer 6
    With device name "new", the waveform driver prepares a new waveform resource. The command assigns the device alias "mysound" and specifies a 6-second buffer.You can eliminate the "type" flag if you combine the device name with the filename. MCI recognizes this combination when you use the following syntax:device_name!element_nameThe exclamation point separates the device name from the filename. The exclamation point should not be delimited by white spaces.The following example opens the RIGHT.WAV file using the "waveaudio" device:open waveaudio!right.wav
    The MCIWAVE driver requires an asynchronous waveform-audio device.
      

  2.   

    char buf[256];
    MCIERROR mciError;
    mciError = mciSendString("open cdaudio", buf, strlen(buf), NULL);
    if(mciError)
    {
          mciGetErrorString(mciError,buf,strlen(buf));
          AfxMessageBox(buf);
          return;
    }
    mciSendString("open xxx.midi type 设备1 ", …);
    mciSendString("play 设备1 repeat", …);
      

  3.   

    我用:
    mciError = mciSendString("open Close.wav type waveaudio alias dillo", 
    buf,strlen(buf),NULL);
    mciError = mciSendString("play dillo repeat",buf,strlen(buf),NULL);
    不能播放声音。
    如果我把waveaudio改成avivideo可以循环播放声音,但程序非常消耗系统资源。我播放的是wav文件,怎么会用avivideo?是不是我的电脑系统有问题?