Anda di halaman 1dari 4

Dim IndexLagu As Integer

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal


hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As
Long

Private Sub CmdAmbil_Click()


Me.CdMusic.DialogTitle = "Open Playlist"
Me.CdMusic.Filter = "PLZ file(*.plz)|*.plz"
Me.CdMusic.ShowOpen
If Me.CdMusic.FileName <> "" Then

Dim tot As Integer


Dim g As Integer
Dim l As ListItem
Dim judul As String
Me.Playlist.ListItems.Clear

tot = 1
Open Me.CdMusic.FileName For Input As #1
While Not EOF(1)
Input #1, judul
For d = 1 To Len(judul)
If Mid(judul, d, 1) = "|" Then
g=d
Exit For
End If
Next d
Set l = Me.Playlist.ListItems.Add(, , Left(judul, g - 1))
l.SubItems(1) = Right(judul, Len(judul) - g)
tot = tot + 1
Wend
Close #1
End If
Me.CdMusic.FileName = ""
End Sub

Private Sub cmdLoadFile_Click()


Dim isi As ListItem
Me.CdMusic.DialogTitle = "Open Music"
Me.CdMusic.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
Me.CdMusic.Filter = "MP3 Files|*.mp3"
Me.CdMusic.FileName = ""
Me.CdMusic.ShowOpen

judul = Split(Me.CdMusic.FileName, vbNullChar)


If UBound(judul) = 0 Then
Set isi = Me.Playlist.ListItems.Add(Text:=Me.CdMusic.FileTitle)
isi.SubItems(1) = Me.CdMusic.FileName
Else
For i = 1 To UBound(judul)
Set isi = Me.Playlist.ListItems.Add(Text:=judul(i))
isi.SubItems(1) = judul(0) & "\" & judul(i)
Next
End If
End Sub

Private Sub cmdPlay_Click()


'Me.Timer1.Enabled = True
End Sub

Private Sub CmdSave_Click()


On Error GoTo salah
Me.CdMusic.FileName = ""
Me.CdMusic.DialogTitle = "Save Playlist"
Me.CdMusic.Filter = "PLZ file(*.plz)|*.plz"
Me.CdMusic.ShowSave
Me.CdMusic.Tag = Me.CdMusic.FileName
If Me.CdMusic.Tag <> "" Then
Open Me.CdMusic.FileName For Output As #1
Seek #1, 1
For i = 1 To Me.Playlist.ListItems.Count
Print #1, Me.Playlist.ListItems(i) & "|" & Me.Playlist.ListItems(i).SubItems(1)
Next i
Close #1
End If
Me.CdMusic.FileName = ""
Exit Sub
salah:
Exit Sub
End Sub

Private Sub Command1_Click()


Me.MpMusic.Stop
Me.MpMusic.currentPosition = 0
Me.Pause.Caption = "Play"
End Sub

Private Sub Form_Load()


IndexLagu = 1
Me.MpMusic.volume = Me.slVolume.Value - Me.slVolume.Max
End Sub
Private Sub Label1_Click()

End Sub

Private Sub mpMusic_EndOfStream(ByVal Result As Long)


Me.Playlist.ListItems(IndexLagu).ForeColor = vbBlack
If IndexLagu = Me.Playlist.ListItems.Count Then
IndexLagu = 1
Else
IndexLagu = IndexLagu + 1
End If
PlayMusic
End Sub

Private Sub Pause_Click()


If Me.Pause.Caption = "Pause" Then
Me.MpMusic.Pause
Me.Pause.Caption = "Play"
Else
If Me.MpMusic.playState = 6 Or Me.MpMusic.playState = 0 Then
IndexLagu = Me.Playlist.SelectedItem.Index
PlayMusic
Else
Me.MpMusic.Play
End If
Me.Pause.Caption = "Pause"
End If
End Sub

Private Sub Playlist_Click()


If Me.Playlist.ListItems.Count > 0 Then
IndexLagu = Me.Playlist.SelectedItem.Index
End If
End Sub

Private Sub PlayList_DblClick()


If Me.Playlist.ListItems.Count > 0 Then
If Me.MpMusic.playState = 1 Or Me.MpMusic.playState = 2 Then Command1_Click
Pause_Click
End If
End Sub

Private Sub slDurasi_Scroll()


Me.MpMusic.currentPosition = Me.slDurasi.Value
End Sub
Private Sub slVolume_Scroll()
If Me.slVolume.Value = Me.slVolume.Min Then
Me.MpMusic.mute = True
Else
Me.MpMusic.mute = False
End If
Me.MpMusic.volume = Me.slVolume.Value
End Sub

Private Sub Timer1_Timer()


Me.slDurasi.Value = Me.MpMusic.currentPosition

menit = Trim(Str(Int((Me.MpMusic.Duration - Me.MpMusic.currentPosition) / 60)))


detik = Trim(Str((Me.MpMusic.Duration - Me.MpMusic.currentPosition) Mod 60))

If Val(menit) < 10 Then menit = "0" & menit


If Val(detik) < 10 Then detik = "0" & detik
Me.LbDurasi.Caption = menit & ":" & detik
Me.slDurasi.Max = Me.MpMusic.Duration
End Sub

Sub PlayMusic()
For i = 1 To Me.Playlist.ListItems.Count
Me.Playlist.ListItems(i).ForeColor = vbBlack
Next i
Me.MpMusic.Open Me.Playlist.ListItems(IndexLagu).SubItems(1)
Me.MpMusic.currentPosition = 0

Me.Playlist.ListItems(IndexLagu).ForeColor = vbBlue
Me.slDurasi.Min = 0
Me.Timer1.Enabled = True
End Sub

Anda mungkin juga menyukai