In my current project I have a self-made audioplayer which is operated trough my musictimer() function. Below is a sub which orders the audioplayer to go to the next song when someone has clicked on a picture. This works perfectly.
Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
If (ListBox1.Items.Count - 1 > songBeingPlayed) Then
musictimer("next")
Else
musictimer("stop")
End If
End Sub
Below there is a sub which orders the player to play the next song when a song is finished playing. This sub also works but only when I have the MessageBox.Show("blabla") line in there. Otherwise it simply ignores the musictimer("next"). Obviously its quite annoying to have popup messages the entire times so I want it gone. Does anyone know whats going on? Im clueless.
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
musictimer("next")
MessageBox.Show("blabla")
End If
End Sub
My very messy musictimer function.
Function musictimer(ByVal action)
If action Is "initial" Then
TextBox1.Text = "0:00"
Timer1.Stop()
secondsCounter = 1
doubledigitsecondCounter = 0
minuteCounter = 0
End If
If action Is "reset" Then
TextBox1.Text = "0:00"
Timer1.Stop()
secondsCounter = 1
doubledigitsecondCounter = 0
minuteCounter = 0
Me.AxWindowsMediaPlayer1.URL = ""
changePlayButton("play")
End If
If action Is "start" Then
If (ListBox1.Items.Count > 0) Then
Me.AxWindowsMediaPlayer1.URL = directoryPath + listboxpl(songBeingPlayed)
AxWindowsMediaPlayer1.Ctlcontrols.play()
Timer1.Start()
changePlayButton("pause")
End If
End If
If action Is "pause" Then
Timer1.Stop()
AxWindowsMediaPlayer1.Ctlcontrols.pause()
changePlayButton("play")
End If
If action Is "next" Then
If (ListBox1.Items.Count - 1 > songBeingPlayed) Then
songBeingPlayed += 1
musictimer("reset")
musictimer("start")
changePlayButton("pause")
Else
musictimer("pause")
End If
End If
If action Is "previous" Then
If (songBeingPlayed > 0) Then
songBeingPlayed -= 1
musictimer("reset")
musictimer("start")
End If
End If
End Function
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…