0

嘿,我有以下代码:

Dim totalDistance as Boolean = False

    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

我想循环声音,直到它到达下一个 IF 语句。但是我想不出一种正确检查它的方法,因为isPlaying将始终保持为,当它进入另一个 IF 语句时,我需要找到一种方法将其设置回假。

任何帮助都会很棒!谢谢!

4

1 回答 1

0

明白了......也许这会满足你的需要:

    If totalDistance <= 210 Then
        'red
        If WMP.URL <> Application.StartupPath + "\red.mp3" Then
            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
        If WMP.URL <> Application.StartupPath + "\yellow.mp3" Then
            WMP.URL = Application.StartupPath + "\yellow.mp3"
            WMP.controls.stop()
            WMP.controls.play()
            WMP.settings.setMode("loop", True)
        End If

        backupLineRED.Visible = True
        backupLineYELLOW.Visible = True
        backupLineGREEN.Visible = False
    ElseIf totalDistance > 671 And totalDistance <= 1000 Then
        'green
        If WMP.URL <> Application.StartupPath + "\green.mp3" Then
            WMP.URL = Application.StartupPath + "\green.mp3"
            WMP.controls.stop()
            WMP.controls.play()
            WMP.settings.setMode("loop", True)
        End If

        backupLineRED.Visible = True
        backupLineYELLOW.Visible = True
        backupLineGREEN.Visible = True
    End If
于 2013-11-08T17:28:16.847 回答