i'd created a game, now thinking of adding background music to it, however i'd tried the codes below..n unsuccessful, anione know what is the mistakes? Thanks a million.

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

'

' sndPlaySound constants

Global Const SND_SYNC = 0

Global Const SND_ASYNC = 1

Global Const SND_NODEFAULT = 2

Global Const SND_LOOP = 8

Global Const SND_NOSTOP = 16

Then in my form I did call it as:

Call sndPlaySound("c:\AWEful[1](2).wav", 1)

Recommended Answers

All 3 Replies

try this code :

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_MEMORY = &H4
Const SND_NODEFAULT = &H2
Const SND_NOSTOP = &H10
Const SND_SYNC = &H0

Private Sub cmdPlay_Click()
Dim Result As Long
Dim SoundFile As String

'  set file name
SoundFile = "C:\DÖNALd.wav"

'  Play wave file 
Result = sndPlaySound(SoundFile, SND_ASYNC)

End Sub

thanks..it works...how about MP3 files? i face a problem here, i need to play certain type of WAV file when any function is being called. And within that function i need certain event run with the music simultaneously....any solution? because the wav file if 12 secs in length, then it needs 12 secs for that particular event to occur..which is not nice..thanks those can help..

use media player control to play mp3 file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.