播放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
DX不能放MP3 如果你要放mp3用mediaplay 如果要游戏中放mp3,不要用DX,用Miles Sound System
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
如果你要放mp3用mediaplay
如果要游戏中放mp3,不要用DX,用Miles Sound System