嘿,我有以下代码:
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语句时,我需要找到一种将其设置为false的方法。
任何帮助将是巨大的!谢谢!
最佳答案
知道...也许这将满足您的需求:
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