CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    111

    Question VB.net loop mp3 until next IF is selected

    Hey all i have the following code:
    Code:
    Dim totalDistance as Boolean = False
    
    Private Sub distanceCheckerTicker()
            Dim totalDistance As Integer = 0 'MAX 1,000
    
            For Each pair As KeyValuePair(Of String, Integer) In mainMenu.backupSensorData
                totalDistance += pair.Value
                'If (pair.Key = "A") Then totalDistance += pair.Value
                'If (pair.Key = "B") Then totalDistance += pair.Value
                'If (pair.Key = "C") Then totalDistance += pair.Value
                'If (pair.Key = "D") Then totalDistance += pair.Value
            Next
    
            If totalDistance <= 210 Then
                'red
                If isPlaying = False Then
                    isPlaying = True
                    WMP.URL = Application.StartupPath + "\red.mp3"
                    WMP.controls.stop()
                    WMP.controls.play()
                    WMP.settings.setMode("loop", True)
                End If
    
                backupLineRED.Visible = True
                backupLineYELLOW.Visible = False
                backupLineGREEN.Visible = False
            ElseIf totalDistance > 210 And totalDistance <= 670 Then
                'yellow
                WMP.URL = Application.StartupPath + "\yellow.mp3"
                WMP.controls.play()
                backupLineRED.Visible = True
                backupLineYELLOW.Visible = True
                backupLineGREEN.Visible = False
            ElseIf totalDistance > 671 And totalDistance <= 1000 Then
                'green
                WMP.URL = Application.StartupPath + "\green.mp3"
                WMP.controls.play()
                backupLineRED.Visible = True
                backupLineYELLOW.Visible = True
                backupLineGREEN.Visible = True
            End If
    
            Debug.Print(totalDistance)
        End Sub
    I am wanting to loop the sound until it reaches the next IF statement. However i cant think of a way to check for it correctly because isPlaying would always stay true and i need to find a way to set it back to false when it goes into another IF statement.

    Any help would be great! Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB.net loop mp3 until next IF is selected

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2008
    Posts
    111

    Re: VB.net loop mp3 until next IF is selected

    Doesnt have anything to do with sounds it seems...

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB.net loop mp3 until next IF is selected

    ask around there for a general answer
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured