Imports WMPLib
Imports System.IO
Imports TagLib.Id3v2
Public Class media_pleyer
Dim numero As Integer
Dim canzoni() As String
Dim i As Integer
Dim musica As String
Dim indice As Integer
Dim playing As Boolean
Private Sub Nexttrack()
indice = List_canzoni.SelectedIndex
indice = indice + 1
If indice = Label4.Text Then
indice = 0
End If
List_canzoni.SelectedIndex = indice
End Sub
Private Sub Previoustrack()
indice = List_canzoni.SelectedIndex
indice = indice - 1
If indice < 0 Then
indice = Label4.Text - 1
End If
List_canzoni.SelectedIndex = indice
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles btn_open.Click
AxWindowsMediaPlayer1.Visible = True
List_canzoni.Visible = True
FolderBrowserDialog1.ShowDialog()
If FolderBrowserDialog1.SelectedPath = "" Then
Exit Sub
Else
canzoni = System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath)
End If
For i = 0 To canzoni.Length - 1
ListBox1.Items.Add(canzoni(i))
List_canzoni.Items.Add(System.IO.Path.GetFileName(canzoni(i)))
Next
numero = List_canzoni.Items.Count
Label4.Text = numero
btn_play.Enabled = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn_play.Click
Timer2.Enabled = True
List_canzoni.SelectedIndex = 0
ListBox1.SelectedIndex = List_canzoni.SelectedIndex
musica = ListBox1.Text
AxWindowsMediaPlayer1.URL = musica
musica = ListBox1.SelectedItem
AxWindowsMediaPlayer1.URL = musica
lb_title.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.name
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles btn_pause.Click
If playing Then
AxWindowsMediaPlayer1.Ctlcontrols.pause()
Else
AxWindowsMediaPlayer1.Ctlcontrols.play()
End If
playing = Not playing
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btn_stop.Click
AxWindowsMediaPlayer1.URL = ""
Timer2.Enabled = False
lb_title.Text = "Title"
Label3.Text = "00:00"
Label6.Text = "00:00"
TrackBar3.Value = 0
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btn_next.Click
Nexttrack()
lb_title.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.name
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles btn_previous.Click
Previoustrack()
lb_title.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.name
End Sub
Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles trc_volume.Scroll
AxWindowsMediaPlayer1.settings.volume = trc_volume.Value
lb_volume.Text = trc_volume.Value.ToString + "%"
End Sub
Private Sub media_pleyer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
List_canzoni.Visible = False
trc_volume.Value = AxWindowsMediaPlayer1.settings.volume
btn_play.Enabled = False
lb_volume.Text = "50%"
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles btn_fullscreen.Click
AxWindowsMediaPlayer1.fullScreen = True
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Timer2.Interval = 60
Label3.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString
Label6.Text = AxWindowsMediaPlayer1.currentMedia.durationString
Dim cur As Integer = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
Dim len As Integer = AxWindowsMediaPlayer1.currentMedia.duration
TrackBar3.Value = cur
TrackBar3.Maximum = len
If TrackBar3.Value = 100 Then
TrackBar3.Value = 0
End If
End Sub
Private Sub AxWindowsMediaPlayer1_Enter(sender As Object, e As EventArgs) Handles AxWindowsMediaPlayer1.Enter
AxWindowsMediaPlayer1.fullScreen = False
End Sub
Private Sub TrackBar3_Scroll(sender As Object, e As EventArgs) Handles TrackBar3.Scroll
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = TrackBar3.Value
End Sub
Private Sub ListBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles List_canzoni.SelectedIndexChanged
Label2.Text = List_canzoni.SelectedIndex
ListBox1.SelectedIndex = List_canzoni.SelectedIndex
musica = ListBox1.Text
AxWindowsMediaPlayer1.URL = musica
Timer2.Enabled = True
lb_title.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.name
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label7.Text = Now.Hour & ":" & Now.Minute & ":" & Now.Second
End Sub
End Class