'Audio Player Main Window Code
Public Class Audio_Player
'Dim i As Integer = 0
#Region "All Controls"
Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpen.Click
Try
Call GetOpenMedia()
TrackBar1.Maximum = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration
Label2.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString
Timer1.Interval = 100
Timer1.Enabled = True
Catch ex As Exception
End Try
End Sub
Private Sub OpenToolStripMenuItem_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Try
Call GetOpenMedia()
TrackBar1.Maximum = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration
Label2.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString
Timer1.Interval = 100
Timer1.Enabled = True
Catch ex As Exception
End Try
End Sub
Private Sub btnPlay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlay.Click
Try
AxWindowsMediaPlayer1.Ctlcontrols.play()
Catch ex As Exception
End Try
End Sub
Private Sub btnPause_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPause.Click
Try
AxWindowsMediaPlayer1.Ctlcontrols.pause()
Catch ex As Exception
End Try
End Sub
Private Sub btnStop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStop.Click
Try
Label1.Text = "00:00"
AxWindowsMediaPlayer1.Ctlcontrols.stop()
Catch ex As Exception
End Try
End Sub
Private Sub btnForword_MouseDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnForword.MouseDown
Try
AxWindowsMediaPlayer1.Ctlcontrols.fastForward()
Catch ex As Exception
End Try
End Sub
Private Sub btnForword_MouseUp(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnForword.MouseUp
Try
AxWindowsMediaPlayer1.Ctlcontrols.play()
Catch ex As Exception
End Try
End Sub
Private Sub GetOpenMedia()
Play_List.DataGridView1.Rows.Clear()
Dim OpenMedia As New OpenFileDialog
OpenMedia.InitialDirectory = System.Environment.SpecialFolder.CommonMusic
OpenMedia.FileName = ""
OpenMedia.Multiselect = False
OpenMedia.Filter = "Audio Files (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc"
OpenMedia.ShowDialog()
If Windows.Forms.DialogResult.OK Then
Play_List.DataGridView1.Rows.Add(OpenMedia.FileName)
AxWindowsMediaPlayer1.URL = OpenMedia.FileName
End If
End Sub
Private Sub OpenFilesToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenFilesToolStripMenuItem.Click
Try
Dim OpenMedia As New OpenFileDialog
OpenMedia.InitialDirectory = System.Environment.SpecialFolder.CommonMusic
OpenMedia.FileName = ""
OpenMedia.Multiselect = True
OpenMedia.Filter = "Audio Files (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc"
OpenMedia.ShowDialog()
If Windows.Forms.DialogResult.OK Then
'For Each str1 As String In OpenMedia.FileNames
' Play_List.ListBox1.Items.Add(str1)
'Next
For Each Str As String In OpenMedia.FileNames
Play_List.DataGridView1.Rows.Add(Str)
Next
End If
Catch ex As Exception
End Try
End Sub
Private Sub Audio_Player_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TrackBar2.Value = 100
ProgressBar1.Value = TrackBar2.Value
AxWindowsMediaPlayer1.settings.volume = TrackBar2.Value
Label3.Text = "Volume: " & TrackBar2.Value & " %"
AxWindowsMediaPlayer1.Visible = False
Timer1.Interval = 100
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
Play_List.Visible = True
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
TrackBar1.Maximum = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration
Label1.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString
TrackBar1.Value = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
Label2.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString
Catch ex As Exception
End Try
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
Try
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = TrackBar1.Value
Catch ex As Exception
End Try
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub TrackBar2_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
Try
AxWindowsMediaPlayer1.settings.volume = TrackBar2.Value
ProgressBar1.Value = TrackBar2.Value
Label3.Text = "Volume: " & TrackBar2.Value & " %"
Catch ex As Exception
End Try
End Sub
Private Sub btnMuteOnOff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMuteOnOff.Click
Try
If AxWindowsMediaPlayer1.settings.mute = False Then
btnMuteOnOff.FlatStyle = FlatStyle.Flat
AxWindowsMediaPlayer1.settings.mute = True
Else
AxWindowsMediaPlayer1.settings.mute = False
btnMuteOnOff.FlatStyle = FlatStyle.Standard
End If
Catch ex As Exception
End Try
End Sub
Private Sub PlayListToolStripMenuItem_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PlayListToolStripMenuItem.Click
If Play_List.Visible = False Then
Play_List.Visible = True
Else
Play_List.Visible = False
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Try
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition - 2
If AxWindowsMediaPlayer1.Ctlcontrols.currentPosition <= 0 Then
Timer2.Enabled = False
End If
Catch ex As Exception
End Try
End Sub
Private Sub btnReverse_MouseDown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReverse.MouseDown
Timer2.Interval = 100
Timer2.Enabled = True
End Sub
Private Sub btnReverse_MouseUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReverse.MouseUp
Timer2.Enabled = False
AxWindowsMediaPlayer1.Ctlcontrols.play()
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
Try
If Not n <= 0 Then
n = n - 1
Me.AxWindowsMediaPlayer1.URL = Play_List.DataGridView1.Item(0, n).Value
Me.TrackBar1.Maximum = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration
Me.Label2.Text = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString
Me.Timer1.Interval = 100
Me.Timer1.Enabled = True
End If
Catch ex As Exception
Beep()
End Try
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Try
If Not n > Play_List.DataGridView1.Rows.Count Then
n = n + 1
AxWindowsMediaPlayer1.URL = Play_List.DataGridView1.Item(0, n).Value
Me.TrackBar1.Maximum = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration
Me.Label2.Text = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString
Me.Timer1.Interval = 100
Me.Timer1.Enabled = True
End If
Catch ex As Exception
Beep()
End Try
End Sub
Private Sub btnOpenSub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenSub.Click
Try
ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)
Catch ex As Exception
End Try
End Sub
Private Sub OpenFilesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFilesToolStripMenuItem1.Click
Try
Dim OpenMedia As New OpenFileDialog
OpenMedia.InitialDirectory = System.Environment.SpecialFolder.CommonMusic
OpenMedia.FileName = ""
OpenMedia.Multiselect = True
OpenMedia.Filter = "Audio Files (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc"
OpenMedia.ShowDialog()
If Windows.Forms.DialogResult.OK Then
'For Each str1 As String In OpenMedia.FileNames
' Play_List.ListBox1.Items.Add(str1)
'Next
For Each Str As String In OpenMedia.FileNames
Play_List.DataGridView1.Rows.Add(Str)
Next
End If
Catch ex As Exception
End Try
End Sub
#End Region
End Class
'Playlist Code
Public Class Play_List
Private Sub DataGridView1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentDoubleClick
Try
Dim i, j As Integer
i = DataGridView1.CurrentRow.Index
j = 0
Audio_Player.AxWindowsMediaPlayer1.URL = Me.DataGridView1.Item(0, i).Value
Audio_Player.TrackBar1.Maximum = Audio_Player.AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration
Audio_Player.Label2.Text = Audio_Player.AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString
Audio_Player.Timer1.Interval = 100
Audio_Player.Timer1.Enabled = True
n = i
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Play_List_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DataGridView1.ReadOnly = True
DataGridView1.AllowUserToAddRows = False
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
End Class
'Module
playlist_module.vb
'Code:
Module playlist_module
Public n As Integer
End Module