source code mp3 player visual basic vb.net

21
©iRoot | Website: iroot.id | Email: [email protected] Hal| 1 Download Project: https://iroot.id/source-code-mp3-player-visual-basic/1506/ Form Player Imports System.Runtime.InteropServices Imports System.IO Imports System.Data.OleDb Public Class PlayeriNaVB Public AudioAPI As New SimplifiedAudioAPI Private OUT_Muted As Boolean Private _Timer As Timer #Region "db" Dim myconnection As New accessdata.koneksidata Dim objconnection As OleDbConnection Dim mycmd As New OleDbCommand Dim objdataadapter As OleDbDataAdapter Dim objdatareader As OleDbDataReader Dim objdataset As New DataSet Dim objdatatable As New DataTable #End Region #Region "mp3songiskynet" Public Class Mp3Song Private _artist As String Private _songName As String Private _path As String Private _panjang As String Public Property Artist() As String Get Return _artist End Get Set(ByVal value As String) Me._artist = value End Set End Property Public Property SongName() As String Get Return _songName End Get Set(ByVal value As String) Me._songName = value End Set End Property Public Property FullName() As String Get Return _path End Get Set(ByVal value As String) Me._path = value End Set End Property Public Property Panjang() As String Get Return _panjang End Get Set(ByVal value As String) Me._panjang = value End Set End Property Public ReadOnly Property Name() Get Dim ch() As Char = {Convert.ToChar(&H20), Convert.ToChar(&H0)} Me._artist = Me._artist.Trim(ch) Me._songName = Me._songName.TrimEnd(ch) Return _artist & " >> " & _songName & Panjang End Get End Property End Class #End Region #Region "deklarasi_tema" Sub tampilkanwarna() '' Me.CZWARNA.Items.Add("Default") '' Me.CZWARNA.Items.Add("Xp Blue") '' Me.CZWARNA.Items.Add("Xp Silver") '' Me.CZWARNA.Items.Add("Xp Olive") '' Me.CZWARNA.Items.Add("Xp Royale") '' Me.CZWARNA.Items.Add("Office2007 Blue") Source Code Mp3 Player Visual Basic VB.NET

Upload: iroot-inc

Post on 14-Apr-2017

328 views

Category:

Software


8 download

TRANSCRIPT

Page 1: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 1

Download Project: https://iroot.id/source-code-mp3-player-visual-basic/1506/

Form Player Imports System.Runtime.InteropServices Imports System.IO Imports System.Data.OleDb Public Class PlayeriNaVB Public AudioAPI As New SimplifiedAudioAPI Private OUT_Muted As Boolean Private _Timer As Timer #Region "db" Dim myconnection As New accessdata.koneksidata Dim objconnection As OleDbConnection Dim mycmd As New OleDbCommand Dim objdataadapter As OleDbDataAdapter Dim objdatareader As OleDbDataReader Dim objdataset As New DataSet Dim objdatatable As New DataTable #End Region #Region "mp3songiskynet" Public Class Mp3Song Private _artist As String Private _songName As String Private _path As String Private _panjang As String Public Property Artist() As String Get Return _artist End Get Set(ByVal value As String) Me._artist = value End Set End Property Public Property SongName() As String Get Return _songName End Get Set(ByVal value As String) Me._songName = value End Set End Property Public Property FullName() As String Get Return _path End Get Set(ByVal value As String) Me._path = value End Set End Property Public Property Panjang() As String Get Return _panjang End Get Set(ByVal value As String) Me._panjang = value End Set End Property Public ReadOnly Property Name() Get Dim ch() As Char = {Convert.ToChar(&H20), Convert.ToChar(&H0)} Me._artist = Me._artist.Trim(ch) Me._songName = Me._songName.TrimEnd(ch) Return _artist & " >> " & _songName & Panjang End Get End Property End Class #End Region #Region "deklarasi_tema" Sub tampilkanwarna() '' Me.CZWARNA.Items.Add("Default") '' Me.CZWARNA.Items.Add("Xp Blue") '' Me.CZWARNA.Items.Add("Xp Silver") '' Me.CZWARNA.Items.Add("Xp Olive") '' Me.CZWARNA.Items.Add("Xp Royale") '' Me.CZWARNA.Items.Add("Office2007 Blue")

Source Code Mp3 Player Visual Basic VB.NET

Page 2: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 2

'' Me.CZWARNA.Items.Add("Office2007 Black") '' Me.CZWARNA.Items.Add("Office2007 Silver") '' Me.CZWARNA.Items.Add("Office2010 Blue") '' Me.CZWARNA.Items.Add("Office2010 Silver") '' Me.CZWARNA.Items.Add("Vista Blue") '' Me.CZWARNA.Items.Add("Vista Black") '' Me.CZWARNA.Items.Add("Vista Silver") '' Me.CZWARNA.Items.Add("Vista Aero") '' Me.CZWARNA.Items.Add("Aero Blue") '' Me.CZWARNA.Items.Add("Aero Black") '' Me.CZWARNA.Items.Add("Aero Silver") '' Me.CZWARNA.Items.Add("MacOS Aqua") '' Me.CZWARNA.Items.Add("MacOS Tiger") '' Me.CZWARNA.Items.Add("MacOS Leopard") '' Me.CZWARNA.Items.Add("MacOS Itun") '' Me.CZWARNA.Items.Add("MacOS Silver") '' Me.CZWARNA.Items.Add("MacOS Brush") End Sub Sub pilihwarna() ''If Me.CZWARNA.Text = "Xp Blue" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.Office2010Blue ''ElseIf Me.CZWARNA.Text = "Xp Silver" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.XpSilver ''ElseIf Me.CZWARNA.Text = "Xp Olive" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.XpOlive ''ElseIf Me.CZWARNA.Text = "Xp Royale" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.XpRoyale ''ElseIf Me.CZWARNA.Text = "Office2007 Blue" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.Office2007Blue ''ElseIf Me.CZWARNA.Text = "Office2007 Black" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.Office2007Black ''ElseIf Me.CZWARNA.Text = "Office2007 Silver" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.Office2007Silver ''ElseIf Me.CZWARNA.Text = "Office2010 Blue" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.Office2010Blue ''ElseIf Me.CZWARNA.Text = "Office2010 Silver" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.Office2010Silver ''ElseIf Me.CZWARNA.Text = "Vista Blue" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.VistaBlue ''ElseIf Me.CZWARNA.Text = "Vista Black" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.VistaBlack ''ElseIf Me.CZWARNA.Text = "Vista Silver" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.VistaSilver ''ElseIf Me.CZWARNA.Text = "Vista Aero" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.VistaAero ''ElseIf Me.CZWARNA.Text = "Aero Blue" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.AeroBlue ''ElseIf Me.CZWARNA.Text = "Aero Black" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.AeroBlack ''ElseIf Me.CZWARNA.Text = "Aero Silver" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.AeroSilver ''ElseIf Me.CZWARNA.Text = "MacOS Aqua" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.MacOSXAqua ''ElseIf Me.CZWARNA.Text = "MacOS Tiger" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.MacOSXTiger ''ElseIf Me.CZWARNA.Text = "MacOS Leopard" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.MacOSXLeopard ''ElseIf Me.CZWARNA.Text = "MacOS Itun" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.MacOSXiTunes ''ElseIf Me.CZWARNA.Text = "MacOS Silver" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.MacOSXSilver ''ElseIf Me.CZWARNA.Text = "MacOS Brush" Then '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.MacOSXBrushed ''Else '' Me.SoNiCz.Style = SkinSoft.OSSkin.SkinStyle.Office2010Blue ''End If End Sub #End Region #Region "deklarasi_volume" Private Const APPCOMMAND_VOLUME_MUTE As Integer = &H80000 Private Const APPCOMMAND_VOLUME_UP As Integer = &HA0000 Private Const APPCOMMAND_VOLUME_DOWN As Integer = &H90000 Private Const WM_APPCOMMAND As Integer = &H319 <DllImport("user32.dll")> Public Shared Function SendMessageW(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr End Function Private Sub BTPLUS_Click(sender As Object, e As EventArgs) Handles BTPLUS.Click SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_UP)) If Me.TrackbarVolumeku.Visible = True Then Me.TrackbarVolumeku.Visible = False Else

Page 3: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 3

Me.TrackbarVolumeku.Visible = True End If End Sub Private Sub BTMINS_Click(sender As Object, e As EventArgs) Handles BTMINS.Click SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_DOWN)) If Me.TrackbarVolumeku.Visible = True Then Me.TrackbarVolumeku.Visible = False Else Me.TrackbarVolumeku.Visible = True End If End Sub Private Sub BTMUTE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTMUTE.Click SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_MUTE)) End Sub Private Sub TrackbarVolumeku_Scroll(sender As Object, e As EventArgs) Handles TrackbarVolumeku.Scroll Me.AxWindowsMediaPlayer1.settings.volume = TrackbarVolumeku.Value End Sub #End Region #Region "perintah_db" Sub simpanini() Try myconnection.close() Dim arrayname() As String = import.FileNames For Each nameku As String In arrayname Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(nameku, "'", "''") & "')", myconnection.open) If import.FileName = Nothing Then Else For Each track As String In import.FileNames sql.Parameters.Add(New OleDb.OleDbParameter("'" & Replace(nameku, "'", "''") & "'", OleDbType.LongVarChar)).Value = (Replace(track, "'", "''")) Next End If sql.ExecuteNonQuery() myconnection.close() End Using myconnection.close() Next Catch ex As Exception myconnection.close() Exit Sub End Try myconnection.close() End Sub Private Sub TambahSoNiDB(ByVal Mp3FilePathsSoNi As String()) Try Me.PlayList.Items.Clear() myconnection.close() mycmd = myconnection.open.CreateCommand mycmd.CommandText = "select * from tbplaylist" objdatareader = mycmd.ExecuteReader While objdatareader.Read Dim kamuku As String = objdatareader.Item("path").ToString If My.Computer.FileSystem.FileExists(kamuku) Then Dim fs As New FileStream(kamuku, FileMode.Open, IO.FileAccess.Read) If fs.Length > 128 Then fs.Position = (fs.Length - 128) Dim TagBytes(2) As Byte fs.Read(TagBytes, 0, 3) Dim tag As String = System.Text.Encoding.Default.GetString(TagBytes) If (tag.ToUpper().Equals("TAG")) Then Dim TitleBytes(30) As Byte fs.Read(TitleBytes, 0, 30) Dim Title As String = System.Text.Encoding.Default.GetString(TitleBytes) Dim ArtistBytes(30) As Byte fs.Read(ArtistBytes, 0, 30) Dim Artist As String = System.Text.Encoding.Default.GetString(ArtistBytes) Dim song As Mp3Song = New Mp3Song Dim media As WMPLib.IWMPMedia = Me.AxWindowsMediaPlayer1.newMedia(kamuku) Dim lenghtsoni As String = media.durationString For m = 1 To (PlayList.Items.Count) + (1) With song .FullName = kamuku

Page 4: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 4

.Artist = m & ". " & Artist .SongName = Title .Panjang = "®" & lenghtsoni End With Next PlayList.DrawMode = DrawMode.OwnerDrawFixed Me.PlayList.Items.Add(song) Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" Else Dim f = New IO.FileInfo(kamuku) Dim song As Mp3Song = New Mp3Song Dim media As WMPLib.IWMPMedia = Me.AxWindowsMediaPlayer1.newMedia(kamuku) Dim lenghtsoni As String = media.durationString For m = 1 To (PlayList.Items.Count) + (1) With song .FullName = kamuku .Artist = m & ". No Artist" .SongName = System.IO.Path.GetFileNameWithoutExtension(f.FullName) .Panjang = "®" & lenghtsoni End With Next PlayList.DrawMode = DrawMode.OwnerDrawFixed Me.PlayList.Items.Add(song) Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" End If fs.Close() Else Dim f = New IO.FileInfo(kamuku) Dim song As Mp3Song = New Mp3Song Dim media As WMPLib.IWMPMedia = Me.AxWindowsMediaPlayer1.newMedia(kamuku) Dim lenghtsoni As String = media.durationString For m = 1 To (PlayList.Items.Count) + (1) With song .FullName = kamuku .Artist = m & ". No Artist" .SongName = System.IO.Path.GetFileNameWithoutExtension(f.FullName) .Panjang = "®" & lenghtsoni End With Next PlayList.DrawMode = DrawMode.OwnerDrawFixed Me.PlayList.Items.Add(song) Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" End If fs.Close() Else End If End While myconnection.close() jmlhitemp() Catch ex As Exception myconnection.close() Exit Sub End Try myconnection.close() End Sub Sub caridata() Try myconnection.close() sonikoneksi.koneksi.Close() Dim DA As OleDb.OleDbDataAdapter DA = New OleDb.OleDbDataAdapter("select * from tbplaylist where path like '" & "%" & Replace(TCARI.Text, "'", "''") & "%" & "'", sonikoneksi.koneksi) Dim DT1 As New DataTable DT1.Clear() DA.Fill(DT1) If DT1.Rows.Count = Nothing Then Else Me.LISTCARI.Items.Clear() mycmd = myconnection.open.CreateCommand mycmd.CommandText = "select * from tbplaylist where path like '" & "%" & Replace(TCARI.Text, "'", "''") & "%" & "'" objdatareader = mycmd.ExecuteReader While objdatareader.Read Dim kamuku As String kamuku = (objdatareader.Item("path").ToString)

Page 5: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 5

Dim f = New IO.FileInfo(kamuku) Dim song As Mp3Song = New Mp3Song With song .FullName = kamuku .SongName = System.IO.Path.GetFileNameWithoutExtension(f.FullName) .Artist = "" End With Me.LISTCARI.Items.Add(song) Me.LISTCARI.ValueMember = "FullName" Me.LISTCARI.DisplayMember = "Name" End While myconnection.close() sonikoneksi.koneksi.Close() End If myconnection.close() sonikoneksi.koneksi.Close() Catch ex As Exception myconnection.close() Exit Sub End Try End Sub Sub hapussatulagu() Try Dim soniw As String = CType(Me.PlayList.SelectedItem, Mp3Song).FullName myconnection.close() mycmd.CommandText = "delete from tbplaylist where path = '" & Replace(soniw, "'", "''") & "'" mycmd.Connection = myconnection.open mycmd.ExecuteNonQuery() myconnection.close() Catch ex As Exception myconnection.close() Exit Sub End Try End Sub Sub hapussemualagu() Try myconnection.close() mycmd.CommandText = "delete from tbplaylist" mycmd.Connection = myconnection.open mycmd.ExecuteNonQuery() myconnection.close() Catch ex As Exception myconnection.close() Exit Sub End Try End Sub Sub tambahplaylistdaridb() Dim SoniSiteZku As String() = Me.import.FileNames() TambahSoNiDB(SoniSiteZku) Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" End Sub #End Region #Region "deklarasi_context" Sub tambahconfolders() If Me.FolderBdialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Try Dim finfo As New IO.DirectoryInfo(FolderBdialog.SelectedPath) For Each s In finfo.GetFiles("*.mp3*", IO.SearchOption.AllDirectories) myconnection.close() Dim Mp3FilePaths As String = finfo.GetFiles("*.mp3*", IO.SearchOption.AllDirectories).ToString Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(s.FullName, "'", "''") & "')", myconnection.open) sql.ExecuteNonQuery() myconnection.close() End Using myconnection.close() Next For Each s In finfo.GetFiles("*.wav*", IO.SearchOption.AllDirectories) myconnection.close() Dim Mp3FilePaths As String = finfo.GetFiles("*.wav*", IO.SearchOption.AllDirectories).ToString Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(s.FullName, "'", "''") & "')", myconnection.open) sql.ExecuteNonQuery()

Page 6: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 6

myconnection.close() End Using myconnection.close() Next For Each s In finfo.GetFiles("*.wmv*", IO.SearchOption.AllDirectories) myconnection.close() Dim Mp3FilePaths As String = finfo.GetFiles("*.wmv*", IO.SearchOption.AllDirectories).ToString Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" Dim nomor As String = "-" Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(s.FullName, "'", "''") & "')", myconnection.open) sql.ExecuteNonQuery() myconnection.close() End Using myconnection.close() Next For Each s In finfo.GetFiles("*.mp4*", IO.SearchOption.AllDirectories) myconnection.close() Dim Mp3FilePaths As String = finfo.GetFiles("*.mp4*", IO.SearchOption.AllDirectories).ToString Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" Dim nomor As String = "-" Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(s.FullName, "'", "''") & "')", myconnection.open) sql.ExecuteNonQuery() myconnection.close() End Using myconnection.close() Next For Each s In finfo.GetFiles("*.3gp*", IO.SearchOption.AllDirectories) myconnection.close() Dim Mp3FilePaths As String = finfo.GetFiles("*.3gp*", IO.SearchOption.AllDirectories).ToString Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" Dim nomor As String = "-" Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(s.FullName, "'", "''") & "')", myconnection.open) sql.ExecuteNonQuery() myconnection.close() End Using myconnection.close() Next For Each s In finfo.GetFiles("*.avi*", IO.SearchOption.AllDirectories) myconnection.close() Dim Mp3FilePaths As String = finfo.GetFiles("*.avi*", IO.SearchOption.AllDirectories).ToString Me.PlayList.ValueMember = "FullName" Me.PlayList.DisplayMember = "Name" Dim nomor As String = "-" Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(s.FullName, "'", "''") & "')", myconnection.open) sql.ExecuteNonQuery() myconnection.close() End Using myconnection.close() Next tambahplaylistdaridb() Catch ex As Exception myconnection.close() End Try End If myconnection.close() End Sub #End Region #Region "untuk_ekstensi" Private _KnownExtensions As New HashSet(Of String)(".wav .mp3 .asf .wma .wmv .wm .asx .wax .wvx .wmx .wpl .dvr-ms .wmd .avi .mpg .mpeg .m1v .mp2 .mpa .mpe .m3u .mid .midi .rmi .aif .aifc .aiff .au .snd .cda .ivf .wmz .wms .mov .m4a .mp4 .m4v .mp4v .3g2 .3gp2 .3gp .3gpp .aac .adt .adts .m2ts".Split) Private Sub PlayList_DragDrop(sender As Object, e As DragEventArgs) Handles PlayList.DragDrop For Each s In DirectCast(e.Data.GetData(DataFormats.FileDrop), String()) If _KnownExtensions.Contains(Path.GetExtension(s)) Then Try myconnection.close() Dim Mp3FilePaths As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop, True), System.String()) Me.PlayList.ValueMember = "FullName"

Page 7: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 7

Me.PlayList.DisplayMember = "Name" Using sql As New OleDb.OleDbCommand("insert into tbplaylist (path) values('" & Replace(s, "'", "''") & "')", myconnection.open) sql.ExecuteNonQuery() myconnection.close() End Using myconnection.close() tambahplaylistdaridb() Catch ex As Exception myconnection.close() Exit Sub End Try End If Next End Sub #End Region #Region "deklarasi_untukmp3" Sub jmlhitemp() Me.LJMITEM.Text = PlayList.Items.Count End Sub Sub padaposisi() PCURRENTPOSISI.Value = 0 End Sub Sub berhenti() AxWindowsMediaPlayer1.Ctlcontrols.stop() PictureBox1.Image = Nothing End Sub Sub kembali() If Me.PlayList.SelectedIndex < 0 Then MsgBox("No song above or selected !!" & vbCrLf & "Please select first song or others !!", MsgBoxStyle.Information, "No song selected :)") End If berhenti() If Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then Me.PlayList.SelectedIndex = (Me.LINURUT.Text) - (1) End Sub Sub terus() berhenti() If Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then Me.PlayList.SelectedIndex = (Me.LINURUT.Text) + (1) End Sub Sub updateplayer() Try If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then With PCURRENTPOSISI .Minimum = 0 .Maximum = CInt(AxWindowsMediaPlayer1.currentMedia.duration) .Value = CInt(AxWindowsMediaPlayer1.Ctlcontrols.currentPosition()) End With Else End If Catch ex As Exception End Try End Sub Sub updateplayersebelum() Try If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then Me.LBLDURASI.Visible = True Me.LBLPOSISI.Visible = True ElseIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPaused Then Me.LBLDURASI.Visible = True Me.LBLPOSISI.Visible = True Else Me.LBLDURASI.Visible = False Me.LBLPOSISI.Visible = False End If Catch ex As Exception End Try End Sub Sub masukkandanbuka() If Me.import.ShowDialog() = Windows.Forms.DialogResult.OK Then simpanini() tambahplaylistdaridb() Else End If End Sub Sub judulsdgmainxv() Dim f = New IO.FileInfo(CType(Me.PlayList.SelectedItem, Mp3Song).FullName) Dim abc As String abc = System.IO.Path.GetFileNameWithoutExtension(f.FullName) Me.Text = abc & " | " End Sub

Page 8: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 8

Sub judulsdgmainxw() Dim f = New IO.FileInfo(CType(Me.LISTCARI.SelectedItem, Mp3Song).FullName) Dim abc As String abc = System.IO.Path.GetFileNameWithoutExtension(f.FullName) Me.Text = abc & " | " End Sub Sub main() Try padaposisi() Timer2.Start() AxWindowsMediaPlayer1.URL = CType(Me.PlayList.SelectedItem, Mp3Song).FullName Me.AxWindowsMediaPlayer1.settings.volume = TrackbarVolumeku.Value Me.LINURUT.Text = Me.PlayList.SelectedIndex judulsdgmainxv() Catch ex As Exception Exit Sub End Try End Sub Sub maincari() Try padaposisi() Timer2.Start() AxWindowsMediaPlayer1.URL = CType(Me.LISTCARI.SelectedItem, Mp3Song).FullName judulsdgmainxw() Catch ex As Exception Exit Sub End Try End Sub Sub urutlagu() If (Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped) Then If (Me.PlayList.SelectedIndex < Me.PlayList.Items.Count - 1) Then Me.PlayList.SelectedIndex = (LINURUT.Text) + (1) main() Me.AxWindowsMediaPlayer1.Ctlcontrols.play() padaposisi() Else Me.PlayList.SelectedIndex = 0 main() Me.AxWindowsMediaPlayer1.Ctlcontrols.play() padaposisi() End If End If End Sub Sub ulanglagu() If (Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped) Then Me.AxWindowsMediaPlayer1.URL = Me.AxWindowsMediaPlayer1.currentMedia.sourceURL Me.AxWindowsMediaPlayer1.Ctlcontrols.play() padaposisi() End If End Sub #End Region #Region "deklarasi_led" Private Sub tChecker_Tick() RefreshProgressbarValues() If (OUTvScalarValue = AudioAPI.OUT_MasterScalar) = False Then OUTvScalarValue = AudioAPI.OUT_MasterScalar RaiseEvent OutVolumeScalarChanged(OUTvScalarValue) End If End Sub Private OUTvScalarValue As Single Private Event OutVolumeScalarChanged(ByVal value As Single) Private Sub RefreshProgressbarValues() Try LedLevelMeter3.Level = AudioAPI.GetPeakValue(SimplifiedAudioAPI.AudioChannels.GET_OUT_MasterPeak) LedLevelMeter1.Level = AudioAPI.GetPeakValue(SimplifiedAudioAPI.AudioChannels.GET_OUT_LeftPeak) LedLevelMeter2.Level = AudioAPI.GetPeakValue(SimplifiedAudioAPI.AudioChannels.GET_OUT_RightPeak) Catch ex As Exception Exit Sub End Try End Sub Sub mainled() OUTvScalarValue = AudioAPI.OUT_MasterScalar : RaiseEvent OutVolumeScalarChanged(OUTvScalarValue) _Timer = New Timer(New System.ComponentModel.Container) _Timer.Interval = 10 AddHandler _Timer.Tick, AddressOf tChecker_Tick _Timer.Enabled = True End Sub

Page 9: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 9

#End Region #Region "deklarasi_hovleav" Private Sub BTPlay_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPlay.MouseHover Me.BTPlay.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Play/Pause Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTPlay, "Click here to play/pause your song !!") End Sub Private Sub BTStop_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTStop.MouseHover Me.BTStop.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Stop Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTStop, "Click here to stop your current playing song !!") End Sub Private Sub BTPause_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPause.MouseHover Me.BTPause.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Seeking Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTPause, "Click here to seeking your current playing song !!") End Sub Private Sub BTBack_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTBack.MouseHover Me.BTBack.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Back Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTBack, "Click here to play previous song !!") End Sub Private Sub BTFile_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTFile.MouseHover Me.BTFile.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Add Song Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTFile, "Click here to add your playlist !!") End Sub Private Sub BTNext_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTNext.MouseHover Me.BTNext.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Next Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000

Page 10: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 10

but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTNext, "Click here to play next song !!") End Sub Private Sub BTPLUS_MouseHover(sender As Object, e As EventArgs) Handles BTPLUS.MouseHover Me.BTPLUS.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Volume Up Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTPLUS, "Click here to increase speaker volume !!") End Sub Private Sub BTMUTE_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTMUTE.MouseHover Me.BTMUTE.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Mute Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTMUTE, "Click here to mute speaker volume !!") End Sub Private Sub BTMINS_MouseHover(sender As Object, e As EventArgs) Handles BTMINS.MouseHover Me.BTMINS.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Volume Down Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTMINS, "Click here to reduce speaker volume !!") End Sub Private Sub BTACAK_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTACAK.MouseHover Me.BTACAK.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Forward Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTACAK, "Click here to forward your playing song !!") End Sub Private Sub BTACAKLAGU_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTACAKLAGU.MouseHover Me.BTACAKLAGU.BackColor = Color.Yellow Dim but As New ToolTip() but.ToolTipTitle = "[Replay Button]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(BTACAKLAGU, "Click here to replay your current playing song !!") End Sub Private Sub LURUT_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles LURUT.MouseHover Dim but As New ToolTip() If Me.LURUT.Text = "F" Then Me.LURUT.BackColor = Color.Yellow but.ToolTipTitle = "[Playlist Status on Forward]"

Page 11: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 11

but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(LURUT, "Your playlist will be play all !!") Else Me.LURUT.BackColor = Color.Green but.ToolTipTitle = "[Playlist Status on Replay]" but.UseFading = True but.UseAnimation = True but.IsBalloon = True but.ShowAlways = True but.AutoPopDelay = 5000 but.InitialDelay = 1000 but.ReshowDelay = 500 but.SetToolTip(LURUT, "Your playlist will be play on current song !!") End If End Sub Private Sub PictureBox1_MouseHover(sender As Object, e As EventArgs) Handles PictureBox1.MouseHover Me.Opacity = 0.9 End Sub Private Sub PictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox1.MouseLeave Me.Opacity = 1 End Sub Private Sub BTStop_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTStop.MouseLeave Me.BTStop.BackColor = Color.Empty End Sub Private Sub BTPlay_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPlay.MouseLeave Me.BTPlay.BackColor = Color.Empty End Sub Private Sub BTPause_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPause.MouseLeave Me.BTPause.BackColor = Color.Empty End Sub Private Sub BTBack_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTBack.MouseLeave Me.BTBack.BackColor = Color.Empty End Sub Private Sub BTFile_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTFile.MouseLeave Me.BTFile.BackColor = Color.Empty End Sub Private Sub BTNext_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTNext.MouseLeave Me.BTNext.BackColor = Color.Empty End Sub Private Sub BTKURANG_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPLUS.MouseLeave Me.BTPLUS.BackColor = Color.Empty End Sub Private Sub BTMUTE_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTMUTE.MouseLeave Me.BTMUTE.BackColor = Color.Empty End Sub Private Sub BTTAMBAH_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTMINS.MouseLeave Me.BTMINS.BackColor = Color.Empty End Sub Private Sub BTACAK_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTACAK.MouseLeave Me.BTACAK.BackColor = Color.Empty End Sub Private Sub BTACAKLAGU_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTACAKLAGU.MouseLeave Me.BTACAKLAGU.BackColor = Color.Empty End Sub Private Sub LURUT_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles LURUT.MouseLeave Me.LURUT.BackColor = Color.Empty End Sub #End Region Private Sub BTFile_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTFile.Click

Page 12: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 12

masukkandanbuka() End Sub Private Sub BTPlay_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTPlay.Click Try If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then AxWindowsMediaPlayer1.Ctlcontrols.pause() Timer2.Stop() Else AxWindowsMediaPlayer1.Ctlcontrols.play() Timer2.Start() End If Catch ex As Exception Exit Sub End Try End Sub Private Sub BTStop_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTStop.Click AxWindowsMediaPlayer1.Ctlcontrols.pause() Timer2.Stop() End Sub Private Sub BTPause_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTPause.Click Try AxWindowsMediaPlayer1.Ctlcontrols.fastForward() Catch ex As Exception Exit Sub End Try End Sub Private Sub BTBack_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTBack.Click Try kembali() main() Catch ex As Exception MsgBox("First song !!", MsgBoxStyle.Information, "Message :)") Exit Sub End Try End Sub Private Sub BTNext_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNext.Click Try terus() main() Catch ex As Exception MsgBox("Back to first song !!", MsgBoxStyle.Information, "Message :)") PlayList.SelectedIndex = 0 Exit Sub End Try End Sub Private Sub BTACAK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTACAK.Click Me.LURUT.Text = "F" End Sub Private Sub BTACAKLAGU_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTACAKLAGU.Click Me.LURUT.Text = "R" End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick updateplayersebelum() Me.LBLJam.Text = Format(Now, "hh : mm : ss") Me.LBLPOSISI.Text = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString End Sub Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick Try PCURRENTPOSISI.Maximum = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration.ToString PCURRENTPOSISI.Increment(1) PCURRENTPOSISI.Maximum = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration.ToString PCURRENTPOSISI.Value = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition.ToString Timer2.Interval = 1000 Catch ex As Exception Exit Sub End Try End Sub Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick

Page 13: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 13

Try If Me.LURUT.Text = "R" Then ulanglagu() Else urutlagu() End If Catch ex As Exception Exit Sub End Try Try If (Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying) Then Me.BTPlay.BackgroundImage = My.Resources.pause Me.Pausenfi.Image = My.Resources.pause_16 Else Me.BTPlay.BackgroundImage = My.Resources.play Me.Pausenfi.Image = My.Resources.play_16 End If Catch ex As Exception Exit Sub End Try End Sub Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick Try If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then Me.PictureBox1.Image = My.Resources.shock Me.Text = Me.Text.Substring(1) & Me.Text.Substring(0, 1) LedLevelMeter1.Visible = True LedLevelMeter2.Visible = True LedLevelMeter3.Visible = True ElseIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then Me.PictureBox1.Image = Nothing LedLevelMeter1.Visible = False LedLevelMeter2.Visible = False LedLevelMeter3.Visible = False ElseIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPaused Then Me.PictureBox1.Image = Nothing LedLevelMeter1.Visible = False LedLevelMeter2.Visible = False LedLevelMeter3.Visible = False End If Catch ex As Exception Exit Sub End Try End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click System.Diagnostics.Process.Start("http://iroot.id/") End Sub Private Sub TambahLaguToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TambahLaguToolStripMenuItem.Click masukkandanbuka() End Sub Private Sub AddFolderStripMenuItem_Click(sender As Object, e As EventArgs) Handles AddFolderStripMenuItem.Click tambahconfolders() End Sub Private Sub HapusLaguToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HapusLaguToolStripMenuItem.Click hapussatulagu() Me.PlayList.Items.Remove(PlayList.SelectedItem) tambahplaylistdaridb() End Sub Private Sub Striphapusemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Striphapusemua.Click hapussemualagu() Me.PlayList.Items.Clear() tambahplaylistdaridb() End Sub Private Sub TambahToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TambahToolStripMenuItem.Click SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_UP)) If Me.TrackbarVolumeku.Visible = True Then Me.TrackbarVolumeku.Visible = False Else Me.TrackbarVolumeku.Visible = True End If

Page 14: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 14

End Sub Private Sub KurangToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KurangToolStripMenuItem.Click SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_DOWN)) If Me.TrackbarVolumeku.Visible = True Then Me.TrackbarVolumeku.Visible = False Else Me.TrackbarVolumeku.Visible = True End If End Sub Private Sub MuteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MuteToolStripMenuItem.Click SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_MUTE)) End Sub Private Sub UrutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrutToolStripMenuItem.Click Me.LURUT.Text = "F" End Sub Private Sub AcakToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AcakToolStripMenuItem.Click Me.LURUT.Text = "R" End Sub Private Sub NextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextToolStripMenuItem.Click Try terus() main() padaposisi() Catch ex As Exception MsgBox("Last song !!", MsgBoxStyle.Information, "Pesan :)") End Try End Sub Private Sub BackToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackToolStripMenuItem.Click Try kembali() main() padaposisi() Catch ex As Exception MsgBox("First song !!", MsgBoxStyle.Information, "Pesan :)") End Try End Sub Private Sub MatikanHangToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MatikanHangToolStripMenuItem.Click FormHelp.Show() End Sub Private Sub PlayeriNaVB_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed Try My.Settings.Save() End Catch ex As Exception Exit Sub End Try End Sub Private Sub PlayerSkyNet_Enter(sender As Object, e As EventArgs) Handles Me.Enter Try If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then AxWindowsMediaPlayer1.Ctlcontrols.pause() Timer2.Stop() Else AxWindowsMediaPlayer1.Ctlcontrols.play() Timer2.Start() End If Catch ex As Exception End Try End Sub Private Sub PlayeriNaVB_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Nfi.Icon = My.Resources.ikonku() e.Cancel = True Me.Hide() Nfi.ShowBalloonTip(8000) End Sub Private Sub PlayerSkyNet_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try tambahplaylistdaridb() myconnection.close()

Page 15: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 15

Me.CZWARNA.Text = My.Computer.Name.ToString 'tampilkanwarna() 'pilihwarna() 'mainled() 'My.Computer.Audio.Play(My.Resources.selamat_fix, AudioPlayMode.Background) Catch ex As Exception myconnection.close() Exit Sub End Try End Sub Private Sub CZWARNA_KeyPress(sender As Object, e As KeyPressEventArgs) Handles CZWARNA.KeyPress e.KeyChar = Chr(0) End Sub Private Sub CSKIN_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CZWARNA.SelectedIndexChanged pilihwarna() End Sub Private Sub AxWindowsMediaPlayer1_CurrentPlaylistChangeEvent(sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_MediaChangeEvent) Handles AxWindowsMediaPlayer1.MediaChange Try LBLDURASI.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString Catch ex As Exception LBLDURASI.Text = "" End Try End Sub Private Sub MainkanDariInternetToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MainkanDariInternetToolStripMenuItem.Click FormInternet.Show() End Sub Private Sub WaktuSeek_Tick(sender As Object, e As EventArgs) Handles WaktuSeek.Tick updateplayer() End Sub Private Sub TCARI_MouseClick(sender As Object, e As MouseEventArgs) Handles TCARI.MouseClick Me.TCARI.Text = "" End Sub Private Sub TCARI_TextChanged(sender As Object, e As EventArgs) Handles TCARI.TextChanged If Me.TCARI.Text = "" Then LISTCARI.Visible = False ElseIf Me.TCARI.Text <> "" Or Me.TCARI.Text <> "Search ..." Then LISTCARI.Visible = True caridata() End If End Sub Private Sub PlayList_DoubleClick(sender As Object, e As EventArgs) Handles PlayList.DoubleClick Try main() padaposisi() If Me.TCARI.Text <> "Search ..." Then TCARI.Text = "Search ..." Me.LISTCARI.Visible = False Else End If Catch ex As Exception Exit Sub End Try End Sub Private Sub PlayList_DragEnter(sender As Object, e As DragEventArgs) Handles PlayList.DragEnter If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then e.Effect = DragDropEffects.All Else e.Effect = DragDropEffects.None End If End Sub Private Sub PlayList_DragOver(sender As Object, e As DragEventArgs) Handles PlayList.DragOver If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.All Else e.Effect = DragDropEffects.None End If End Sub Private Sub PlayList_KeyPress(sender As Object, e As KeyPressEventArgs) Handles PlayList.KeyPress Try If e.KeyChar = Chr(13) Then

Page 16: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 16

main() padaposisi() If Me.TCARI.Text <> "Search ..." Then TCARI.Text = "Search ..." Me.LISTCARI.Visible = False Else End If Else End If Catch ex As Exception Exit Sub End Try End Sub Private Sub LISTCARI_DoubleClick(sender As Object, e As EventArgs) Handles LISTCARI.DoubleClick Try maincari() padaposisi() TCARI.Text = "Search ..." Me.LISTCARI.Visible = False Catch ex As Exception End Try End Sub Private Sub LISTCARI_KeyPress(sender As Object, e As KeyPressEventArgs) Handles LISTCARI.KeyPress If e.KeyChar = Chr(13) Then TCARI.Text = "Search ..." maincari() padaposisi() Me.LISTCARI.Visible = False End If End Sub Private Sub PCURRENTPOSISI_Click(sender As Object, e As EventArgs) Handles PCURRENTPOSISI.Click Dim CP As Point = PCURRENTPOSISI.PointToClient(Cursor.Position) PCURRENTPOSISI.Value = PCURRENTPOSISI.Minimum + (PCURRENTPOSISI.Maximum - PCURRENTPOSISI.Minimum) * CP.X / PCURRENTPOSISI.Width Try AxWindowsMediaPlayer1.Ctlcontrols.pause() AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = PCURRENTPOSISI.Value AxWindowsMediaPlayer1.Ctlcontrols.play() updateplayer() Application.DoEvents() Catch ex As Exception End Try End Sub Private Sub PlayList_DrawItem(sender As Object, e As DrawItemEventArgs) Handles PlayList.DrawItem e.DrawBackground() If e.Index > -1 Then Using sf As New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Far, .Trimming = StringTrimming.EllipsisCharacter, .FormatFlags = StringFormatFlags.NoWrap} Using br As New SolidBrush(Color.Lime) With e.Graphics If (CType(Me.PlayList.Items.Item(e.Index), Mp3Song).Name).ToString.Contains(ChrW(174)) Then If CBool(e.State And DrawItemState.Selected) Then Dim Elements() As String = (CType(Me.PlayList.Items.Item(e.Index), Mp3Song).Name).ToString.Split(ChrW(174)) .DrawString(Elements(0), e.Font, Brushes.White, New Rectangle(0, e.Bounds.Y, e.Bounds.Width \ 1, e.Bounds.Height), sf) sf.Alignment = StringAlignment.Far .DrawString(Elements(1), e.Font, Brushes.White, New Rectangle(e.Bounds.Width \ 2, e.Bounds.Y, e.Bounds.Width \ 2, e.Bounds.Height), sf) Else Dim Elements() As String = (CType(Me.PlayList.Items.Item(e.Index), Mp3Song).Name).ToString.Split(ChrW(174)) .DrawString(Elements(0), e.Font, br, New Rectangle(0, e.Bounds.Y, e.Bounds.Width \ 2, e.Bounds.Height), sf) sf.Alignment = StringAlignment.Far .DrawString(Elements(1), e.Font, br, New Rectangle(e.Bounds.Width \ 2, e.Bounds.Y, e.Bounds.Width \ 2, e.Bounds.Height), sf) End If Else End If End With br.Dispose() End Using End Using

Page 17: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 17

End If End Sub Private Sub Nfi_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Nfi.MouseDoubleClick Nfi.Icon = Nothing Me.Show() End Sub Private Sub ExitandOut_Click(sender As Object, e As EventArgs) Handles ExitandOut.Click Try Me.Hide() My.Settings.Save() End Catch ex As Exception End Exit Sub End Try End Sub Private Sub Opennfi_Click(sender As Object, e As EventArgs) Handles Opennfi.Click Nfi.Icon = Nothing Me.Show() End Sub Private Sub Helpnfi_Click(sender As Object, e As EventArgs) Handles Helpnfi.Click FormHelp.Show() End Sub Private Sub Exitnfi_Click(sender As Object, e As EventArgs) Handles Exitnfi.Click Try Nfi.Icon = Nothing AxWindowsMediaPlayer1.Ctlcontrols.stop() myconnection.close() sonikoneksi.koneksi.Close() My.Settings.Save() End Catch ex As Exception End Exit Sub End Try End Sub Private Sub Pausenfi_Click(sender As Object, e As EventArgs) Handles Pausenfi.Click Try If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then AxWindowsMediaPlayer1.Ctlcontrols.pause() Timer2.Stop() Else AxWindowsMediaPlayer1.Ctlcontrols.play() Timer2.Start() End If Catch ex As Exception Exit Sub End Try End Sub Private Sub Mutenfi_Click(sender As Object, e As EventArgs) Handles Mutenfi.Click SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_MUTE)) End Sub Private Sub ToolStripSettings_Click(sender As Object, e As EventArgs) Handles ToolStripSettings.Click With FormSetting .Show() End With End Sub End Class

Page 18: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 18

Form Setting

Public Class FormSetting Private Sub TBALANCE_Scroll(sender As Object, e As EventArgs) Handles TBALANCE.Scroll Try With PlayeriNaVB .AxWindowsMediaPlayer1.settings.balance = TBALANCE.Value End With Catch ex As Exception Exit Sub End Try End Sub Private Sub CRESET_CheckedChanged(sender As Object, e As EventArgs) Handles CRESET.CheckedChanged Try With PlayeriNaVB .AxWindowsMediaPlayer1.settings.balance = 0 End With Catch ex As Exception Exit Sub End Try End Sub End Class

Page 19: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 19

Form Internet

Imports System.IO Public Class FormInternet #Region "deklarasi" Sub hentaks() Try If PlayeriNaVB.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then PlayeriNaVB.AxWindowsMediaPlayer1.Ctlcontrols.pause() PlayeriNaVB.Timer2.Stop() Else PlayeriNaVB.AxWindowsMediaPlayer1.Ctlcontrols.play() PlayeriNaVB.Timer2.Start() End If Catch ex As Exception End Try End Sub Sub main() Try PlayeriNaVB.AxWindowsMediaPlayer1.URL = Me.TURL.Text PlayeriNaVB.AxWindowsMediaPlayer1.Ctlcontrols.play() Catch ex As Exception End Try End Sub Sub berhenti() PlayeriNaVB.AxWindowsMediaPlayer1.Ctlcontrols.stop() End Sub Sub mainkanhabis() Try If Me.TURL.Text = "" Then MsgBox("Insert your song URLs, Ex: http://iroot.id/yoursong.mp3 !!", MsgBoxStyle.Critical, "Notice !!") ElseIf Me.TURL.Text <> "" And Me.TPLAY.Text = "Play" Then Me.TPLAY.Text = "Stop" main() Else Me.TPLAY.Text = "Play" berhenti() End If Catch ex As Exception End Try End Sub #End Region #Region "deklarasi_koneksi" Public Function IsConnectionAvailable() As Boolean Dim objUrl As New System.Uri("http://iroot.id") Dim objWebReq As System.Net.WebRequest objWebReq = System.Net.WebRequest.Create(objUrl) Dim objresp As System.Net.WebResponse Try objresp = objWebReq.GetResponse objresp.Close() objresp = Nothing Return True Catch ex As Exception objresp = Nothing objWebReq = Nothing Return False End Try End Function #End Region Private Sub TPLAY_Click(sender As Object, e As EventArgs) Handles TPLAY.Click If IsConnectionAvailable() = True Then Try If TURL.Text = "Ex: http://iroot.id/yoursong.mp3" Then MsgBox("Input your valid URLs !!" & vbCrLf & "Example of song URLs:" & vbCrLf & "http://iroot.id/yoursong.mp3", MsgBoxStyle.Critical, "Notice !!") Exit Sub Else Dim hasilbalik As String LK.Text = StrReverse(TURL.Text) hasilbalik = Mid(LK.Text, 1, 4) LK.Text = hasilbalik If (LK.Text = "3pm." Or LK.Text = "vaw." Or LK.Text = "4pm." Or LK.Text = "pg3." Or LK.Text = "vmw." Or LK.Text = "iva." Or LK.Text = "gpm." Or LK.Text = "amw." Or LK.Text = "gepm." Or LK.Text = "2pg3." Or LK.Text = "2g3." Or LK.Text = "e4m." Or LK.Text = "smw.") And (TPLAY.Text = "Play" Or TPLAY.Text = "Stop") Then mainkanhabis() Else

Page 20: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 20

MsgBox("Format is not supported !!" & vbCrLf & "Example of song URLs:" & vbCrLf & "http://iroot.id/yoursong.mp3", MsgBoxStyle.Critical, "Notice !!") Exit Sub End If End If Catch ex As Exception Exit Sub End Try Else MsgBox("No internet connection !!" & vbCrLf & "Please check your internet connection and try again !!", MsgBoxStyle.Information, "Notice !!") Exit Sub End If End Sub Private Sub TPAUSE_Click(sender As Object, e As EventArgs) Handles TPAUSE.Click Try If Me.TPAUSE.Text = "Pause" Then Me.TPAUSE.Text = "Resume" hentaks() Else Me.TPAUSE.Text = "Pause" hentaks() End If Catch ex As Exception End Try End Sub End Class

Page 21: Source Code Mp3 Player Visual Basic VB.net

©iRoot | Website: iroot.id | Email: [email protected] Hal| 21

Form Help

Imports DevComponents.DotNetBar Public Class FormHelp Private Sub Button1_Click(sender As Object, e As EventArgs) Me.Close() End Sub Private Sub TCONTRIBUTE_Tick(sender As Object, e As EventArgs) Handles TCONTRIBUTE.Tick If Me.Label7.Top > -490 Then Me.Label7.Top = Me.Label7.Top - 1 Else Me.Label7.Top = Me.Label7.Top + 750 End If End Sub Private Sub Label7_MouseHover(sender As Object, e As EventArgs) Handles Label7.MouseHover balloonTipFocus.Enabled = True BalloonTipHover.Enabled = True Dim b As DevComponents.DotNetBar.Balloon = New DevComponents.DotNetBar.Balloon() b.Style = eBallonStyle.Alert b.CaptionImage = CType(balloonTipFocus.CaptionImage.Clone(), Image) b.CaptionText = "Tips and Information :)" b.Text = "Do you want your name and your web/blog URL here? Make a donation and please click this link." b.AlertAnimation = eAlertAnimation.TopToBottom b.AutoResize() b.AutoClose = True b.AutoCloseTimeOut = 7 b.Owner = Me b.Show(Label7, False) Me.TCONTRIBUTE.Enabled = False Me.Label7.ForeColor = Color.Red End Sub Private Sub Label7_MouseLeave(sender As Object, e As EventArgs) Handles Label7.MouseLeave Me.TCONTRIBUTE.Enabled = True Me.Label7.ForeColor = Color.Black End Sub Private Sub BalloonTipHover_BalloonDisplaying(sender As Object, e As EventArgs) Handles BalloonTipHover.BalloonDisplaying Dim p As Point = Control.MousePosition p.Offset(-BalloonTipHover.BalloonControl.TipOffset, BalloonTipHover.BalloonControl.TipLength + 4) BalloonTipHover.BalloonControl.Location = p End Sub Private Sub Label7_Click(sender As Object, e As EventArgs) Handles Label7.Click System.Diagnostics.Process.Start("http://iroot.id/") End Sub End Class

Be respect to us

Mail: [email protected]