VB 2005: How to loop sound?

Dear Experts:

I would like to learn from you how to loop a sound.

I owe you already a lot!

Thanks!

duta
dutaAsked:
Who is Participating?
 
aherpsConnect With a Mentor Commented:
Hi duta,

VB2005 has the My.Computer.Audio.Play method.  For looping, you set play mode to BackgroundLoop as shown below:



Sub PlayLoopingBackgroundSoundFile()
    My.Computer.Audio.Play("C:\Waterfall.wav", _
        AudioPlayMode.BackgroundLoop)
End Sub

Open in new window

0
 
aherpsCommented:
Theres more information here:

http://msdn.microsoft.com/en-us/library/w032hx3c.aspx

Outlining stopping background loops etc.

Have fun!
0
 
Wayne Taylor (webtubbs)Connect With a Mentor Commented:
....and to add to aherps suggestion, to stop the sound, call the Stop method....

    My.Computer.Audio.Stop()

Wayne
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
dutaAuthor Commented:
Can we set the number of loops?  In other words, can we stop loop after three loops?

Thanks a lot!
0
 
aherpsCommented:
If you embed within a for loop, for a limited number of plays something like:


Dim d As Integer
For d = 0 To 2
My.Computer.Audio.Play("C:\Waterfall.wav",AudioPlayMode.Background)
Next d
End Sub

Open in new window

0
 
dutaAuthor Commented:
it fails to loop.
But you answered my original question.
I am going to post a new question regarding how to loop a sound for a limited time.

Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.