How to play a wav-file without affecting other parts of an application?

I'm making a screensaver with a bouncing picturebox, which is controlled by a timer.
Now, I want to add some sounds to it. I have a timer with the command to excecute the wav-file every now and then. BUT, everything else stands still while the wav-file is being played. And when it's finished, everything is back in order.
So is there any way to play soundfiles WITHOUT pausing the rest of an application?

Thank you!
Caminman
LVL 1
CaminmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mark2150Commented:
Don't know how you're coding this but sounds like you're polling the sound driver while waiting for it to complete. This will tie up your station.

The MultiMedia control will fire an *event* at the end of the music. This allows your event handler to restart the music without having to tie up the program by polling.

You can loosen up a polling loop by placing a doevents inside. This will cede some execution to other threads.

I've got a code snippet on my web page that shows how to play music and such that might be a help.

Visit: www.cyberchute.com/rvbus/madmark

M
0
Erick37Commented:
If you are using sndPlaySound, use the SND_ASYNC flag.

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_FILENAME = &H20000
Private Const SND_ASYNC = &H1
Private Const SND_LOOP = &H8
Private Const SND_MEMORY = &H4
Private Const SND_SYNC = &H0
Private Const SND_NOSTOP = &H10
Private Const SND_NODEFAULT = &H2


Private Sub Command1_Click()
    sndPlaySound "c:\windows\msremind.wav", _
        SND_ASYNC Or SND_FILENAME Or SND_NODEFAULT
    MsgBox "Sound is playing"
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erick37Commented:
Same is true with PlaySound:

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Sub Command1_Click()
    Call PlaySound("c:\windows\msremind.wav", 0&, _
        SND_ASYNC Or SND_FILENAME Or SND_NODEFAULT)
    MsgBox "Sound is playing"
End Sub
0
CaminmanAuthor Commented:
By answering so quickly and so well, I will gladly give you full points!!

Thank you very much ERICK!!
 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.