fortunatekidz
New member
- Joined
- Mar 2, 2018
- Messages
- 4
- Programming Experience
- Beginner
Hi , coding master in visual basic studio. I have a project in building mp3 player, It almost done, but there is one problem which is the media player won't auto-play next song. I tried find it online but they don't work in my project. Hope all masters here could help me...Thanks alot
VB.NET:
Imports AxWMPLib
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem.ToString
currentTrack = ListBox1.SelectedIndex
End Sub
Private Sub AxWindowsMediaPlayer1_Enter(sender As Object, e As EventArgs) Handles AxWindowsMediaPlayer1.Enter
If (AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped) Then
Timer1.Enabled = True
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
AxWindowsMediaPlayer1.Ctlcontrols.stop()
Else
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
currentTrack += 1
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (FolderBrowserDialog1.ShowDialog = DialogResult.OK) Then
TextBox1.Text = FolderBrowserDialog1.SelectedPath.ToString
End If
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
ListBox1.Items.Clear()
If Not TextBox1.Text = "" Then
For Each file As String In My.Computer.FileSystem.GetFiles(TextBox1.Text, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")
ListBox1.Items.Add(file)
Next
End If
End Sub
Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles Timer1.Tick
If (AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped) Then
If (ListBox1.SelectedIndex < ListBox1.Items.Count + 1) Then
ListBox1.SelectedIndex = ListBox1.SelectedIndex - 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
AxWindowsMediaPlayer1.Ctlcontrols.play()
End If
End If
End Sub
End Class