Home All Groups Group Topic Archive Search About

playing & re-playing 7 .wav files

Author
25 May 2006 1:52 PM
Mr. Murad Jamal
Dear guys,
I have 7  .wav files in C:\ directory [named: 1.wav, 2.wav, ..., 7.wav], I'd
play them all by clicking on "cmdStart" button on a Visual Basic 2005-
Windows Application Form.

I thought I should use this segment of code to get this thing done:



Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdStart.Click

        Dim i As Integer = 1

        While i < 8
            My.Computer.Audio.Play("C:\" & i & ".wav",
AudioPlayMode.Background)
            i += 1
        End While

    End Sub




But when I run the application, it ONLY plays the last .wav file (7.wav) !!
What I need is to play them all, one by one, that is, 1.wav .. then 2.wav ..
then ..etc.. until 7.wav, AND i also want to re-loop [re-play these files]
this operation ( that is, after finishing the first loop of these 7  .wav
files, the application should start over again from 1.wav ... till 7.wav ...
and so on ..) !

what code line or segment should i add to the above segment to get this done
!!
I'd highly appreciate your help guys !!

Thanx in advance !

Author
25 May 2006 8:02 PM
gene kelley
On Thu, 25 May 2006 06:52:02 -0700, Mr. Murad Jamal
<MrMuradJa***@discussions.microsoft.com> wrote:

Show quoteHide quote
>Dear guys,
>I have 7  .wav files in C:\ directory [named: 1.wav, 2.wav, ..., 7.wav], I'd
>play them all by clicking on "cmdStart" button on a Visual Basic 2005-
>Windows Application Form.
>
>I thought I should use this segment of code to get this thing done:
>
>
>
>Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles cmdStart.Click
>
>        Dim i As Integer = 1
>
>        While i < 8
>            My.Computer.Audio.Play("C:\" & i & ".wav",
>AudioPlayMode.Background)
>            i += 1
>        End While
>
>    End Sub
>
>
>
>
>But when I run the application, it ONLY plays the last .wav file (7.wav) !!
>What I need is to play them all, one by one, that is, 1.wav .. then 2.wav ..
>then ..etc.. until 7.wav, AND i also want to re-loop [re-play these files]
>this operation ( that is, after finishing the first loop of these 7  .wav
>files, the application should start over again from 1.wav ... till 7.wav ...
>and so on ..) !
>
>what code line or segment should i add to the above segment to get this done
>!!
>I'd highly appreciate your help guys !!
>
>Thanx in advance !

If this is simply background sounds for the app, this will proabaly
work (air code), but you will probably need to put this in it's own
thread for best performance.

Dim i As Integer = 1

        While i < 8
            My.Computer.Audio.Play("C:\" & i & ".wav",
    AudioPlayMode.WaitToComplete)
    If i = 7 then
      i = 1
    Else          
    i += 1
        End While

    End Sub

Gene
Author
27 May 2006 2:22 PM
Mr. Murad Jamal
thanx alot this is awesome .. i will try to use background worker for putting
it on its own thread !!

Show quoteHide quote
"gene kelley" wrote:

> On Thu, 25 May 2006 06:52:02 -0700, Mr. Murad Jamal
> <MrMuradJa***@discussions.microsoft.com> wrote:
>
> >Dear guys,
> >I have 7  .wav files in C:\ directory [named: 1.wav, 2.wav, ..., 7.wav], I'd
> >play them all by clicking on "cmdStart" button on a Visual Basic 2005-
> >Windows Application Form.
> >
> >I thought I should use this segment of code to get this thing done:
> >
> >
> >
> >Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As
> >System.EventArgs) Handles cmdStart.Click
> >
> >        Dim i As Integer = 1
> >
> >        While i < 8
> >            My.Computer.Audio.Play("C:\" & i & ".wav",
> >AudioPlayMode.Background)
> >            i += 1
> >        End While
> >
> >    End Sub
> >
> >
> >
> >
> >But when I run the application, it ONLY plays the last .wav file (7.wav) !!
> >What I need is to play them all, one by one, that is, 1.wav .. then 2.wav ..
> >then ..etc.. until 7.wav, AND i also want to re-loop [re-play these files]
> >this operation ( that is, after finishing the first loop of these 7  .wav
> >files, the application should start over again from 1.wav ... till 7.wav ...
> >and so on ..) !
> >
> >what code line or segment should i add to the above segment to get this done
> >!!
> >I'd highly appreciate your help guys !!
> >
> >Thanx in advance !
>
> If this is simply background sounds for the app, this will proabaly
> work (air code), but you will probably need to put this in it's own
> thread for best performance.
>
>  Dim i As Integer = 1
>
>         While i < 8
>             My.Computer.Audio.Play("C:\" & i & ".wav",
>     AudioPlayMode.WaitToComplete)
>     If i = 7 then
>       i = 1
>     Else          
>     i += 1
>         End While
>
>     End Sub
>
> Gene
>