嘿,我有以下代码:
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 将始终保持 true 并且当它进入另一个时我需要找到一种方法将其设置为false IF声明。
任何帮助都会很棒!谢谢!
答案 0 :(得分: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