?
Solved

VB 2005: How to loop sound?

Posted on 2008-11-15
6
Medium Priority
?
377 Views
Last Modified: 2013-11-26
Dear Experts:

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

I owe you already a lot!

Thanks!

duta
0
Comment
Question by:duta
  • 3
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
aherps earned 1800 total points
ID: 22969548
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
 
LVL 7

Expert Comment

by:aherps
ID: 22969553
Theres more information here:

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

Outlining stopping background loops etc.

Have fun!
0
 
LVL 48

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 200 total points
ID: 22969554
....and to add to aherps suggestion, to stop the sound, call the Stop method....

    My.Computer.Audio.Stop()

Wayne
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:duta
ID: 22969701
Can we set the number of loops?  In other words, can we stop loop after three loops?

Thanks a lot!
0
 
LVL 7

Expert Comment

by:aherps
ID: 22969712
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
 

Author Comment

by:duta
ID: 22969749
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question