我这里只有一个用DirectX播放WAV文件的例子,能不能用DirectX播放MP3文件就不知道了。

解决方案 »

  1.   

    播放WAV文件的例子代码:
    Option Explicit
    Dim DirectX7Obj As New DirectX7
    Dim DirectSoundObj As DirectSound
    Dim SoundBuffer As DirectSoundBufferPrivate Sub Form_Load()
      Set DirectSoundObj = DirectX7Obj.DirectSoundCreate("")
      DirectSoundObj.SetCooperativeLevel Me.hWnd, DSSCL_PRIORITY
      Dim bufferDesc As DSBUFFERDESC
      Dim waveFormat As WAVEFORMATEX
      bufferDesc.lFlags = DSBCAPS_STATIC
      Set SoundBuffer = DirectSoundObj.CreateSoundBufferFromFile("e:\Amphora.wav", bufferDesc, waveFormat)
      SoundBuffer.Play 1   '0播放一次,1循环播放
    End Sub
      

  2.   

    DX不能放MP3
    如果你要放mp3用mediaplay
    如果要游戏中放mp3,不要用DX,用Miles Sound System