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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

aherpsCommented:
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

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
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)Commented:
....and to add to aherps suggestion, to stop the sound, call the Stop method....

    My.Computer.Audio.Stop()

Wayne
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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
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
.NET Programming

From novice to tech pro — start learning today.