Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a function, in which i'll pass my audio file path as parameter and will play the audio file. Nw my doubt is how can i play tat audio file for 2 times continuously using C#.

We have play() and playlooping() but play will run the audio file only once and playlooping will run the audio file repeatedly but nw i need to run the audio file for twice or thrice.

public void mysound(string pat)
        {
            m = "C:\\WINDOWS\\Media\\ringin.wav";
            anno.SoundLocation =pat ;
                anno.Play();
        }



Can anyone help me on this.
Pls rply me fast
Thanks in advance
Posted
Updated 14-May-10 2:26am
v3

aswinrajkumar wrote:
i need to run the audio file for twice or thrice

Why not just put that in a loop of 2 or 3 as required?
 
Share this answer
 
We can, but it will play simultaneously but i need tat to be done one after another.
 
Share this answer
 
Comments
Sandeep Mewara 12-May-10 1:52am    
Please use comment feature instead of pushing an answer button to reply someone back. If you use comment, then i will also get an email about the same notifying me about some activity.

About playing one after another, put a lag based on the music time. Execution of code definitely is one after another... not simultaneously. So putting some sort of delay should do it, what say?
aswinrajkumar 12-May-10 2:28am    
Oh.. k Sandeep im new to this forum.. Sandey u mean tat i wanna record the sound twice in a single file or need to keep the timer for it
You could actually run a simple loop to play the sound twice and then break out of the loop.
 
Share this answer
 
Why don't you use a sound editing program (like Audacity, which is free, BTW), and create a new double-ring version of the file you're trying to play, and only play it once.
 
Share this answer
 
Comments
Ryan McBeth 14-May-10 9:19am    
I agree with John. Sometimes the easiest programming answer has nothing to do with programming.
Hi guys,
Thanks for your suggestions

I got the output for that.

The code is

public void mysound(string pat)
        {
            m = "C:\\WINDOWS\\Media\\ringin.wav";
            anno.SoundLocation =pat ;
             for(int i=1;i<=3;i++)
             {
                  anno.PlaySync();
                   Thread.Sleep(100);
             }
        }

:thumbsup: :-\
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900