|
-
Mar 29th, 2002, 07:52 PM
#1
Thread Starter
Lively Member
playing mp3's through api
the mci and media player controls are too slow, hitting the play button swaps the image with another, but its getting slowed down while the control plays the file. I'm thinking that using the api will be faster and allow the swap to occur instantaneously (or pretty close)
anybody know of any documentation on using the api to play mp3 files (or wav, mid, etc, a player would be pretty useless if it only played one file type) or have any tips? much appreciated.
-
Apr 2nd, 2002, 04:59 AM
#2
Junior Member
Play wav using DX
This is pasted from one of my games. hope it helps. it plays wav files in buffers. I stick to this method, i think its great.
Public DirectX7Obj As New DirectX7
Public DirectSoundObj As DirectSound
Public Level1Music As DirectSoundBuffer
Public Level2Music As DirectSoundBuffer
Public StartupMusic As DirectSoundBuffer
Public WallHit As DirectSoundBuffer
Public DamageBrick As DirectSoundBuffer
Public BrickDestroy As DirectSoundBuffer
Public HardBrickDestroy As DirectSoundBuffer
Public MetalHit As DirectSoundBuffer
Public Clap As DirectSoundBuffer
Public PaddleHit As DirectSoundBuffer
Public EjectBall As DirectSoundBuffer
Public GameOverLaugh As DirectSoundBuffer
Sub InitSound()
InitDirectSound
ChDir CheckPath(App.Path)
Set Level1Music = CreateSound("SOUND\Level1Music.wav")
Set Level2Music = CreateSound("SOUND\Level2Music.wav")
Set StartupMusic = CreateSound("SOUND\StartupMusic.wav")
Set MetalHit = CreateSound("SOUND\MetalHit.wav")
Set BrickDestroy = CreateSound("SOUND\BrickDestroy.wav")
Set HardBrickDestroy = CreateSound("SOUND\HardBrickDestroy.wav")
Set DamageBrick = CreateSound("SOUND\DamageBrick.wav")
Set WallHit = CreateSound("SOUND\WallHit.wav")
Set Clap = CreateSound("SOUND\Clap.wav")
Set PaddleHit = CreateSound("SOUND\PaddleHit.wav")
Set EjectBall = CreateSound("SOUND\EjectBall.wav")
Set GameOverLaugh = CreateSound("SOUND\GameOverLaugh.wav")
End Sub
Sub InitDirectSound()
Set DirectSoundObj = DirectX7Obj.DirectSoundCreate("")
DirectSoundObj.SetCooperativeLevel Startup.hwnd, DSSCL_PRIORITY
End Sub
Function CreateSound(FileName As String) As DirectSoundBuffer
Dim BufferDesc As DSBUFFERDESC
Dim WaveFormat As WAVEFORMATEX
BufferDesc.lFlags = DSBCAPS_STATIC
Set CreateSound = _
DirectSoundObj.CreateSoundBufferFromFile(FileName, BufferDesc, WaveFormat)
End Function
Public Sub PlaySound(sound As DirectSoundBuffer, CloseFirst As Boolean, LoopSound As Boolean)
If CloseFirst Then
sound.Stop
sound.SetCurrentPosition 0
End If
If LoopSound Then
sound.Play 1
Else
sound.Play 0
End If
End Sub
-
Apr 2nd, 2002, 05:01 AM
#3
Junior Member
remember to activate direct x in references inside vb :=)
-
Apr 2nd, 2002, 08:35 AM
#4
Good Ol' Platypus
I'm currently working on an Mp3 decompressor (Mp3 -> Wav) so if I ever finish I'll let you know.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|