Rabu, 22 September 2010

Buat MP3 Player dengan VB 6.0

1. Buka program VB 6.0 dan pilih Standart.EXE
2. Masukkan 5 buah CommandButton, 1 buah komponen media player (msdxm.ocx) dan 2 buah ListBox kedalam Form1. Atur Posisinya seperti gambar di bawah ini:

3. Ganti Caption dari setiap tombol menjadi :

4. Masukkan 1 buah Form (Form2) kedalam Projects dan tambahkan 1 buah DriveListbox, 1 buah DirListbox, 2 buah CommandButton dan 1 buah FileListBox kedalam Form2. Atur seperti gambar di bawah ini:

Ubah Caption Command1 = Add dan Caption Command2 = Cancel
Untuk FileListBox ubah Pattern = *.mp3
Tampilan Form2 akan menjadi seperti ini :


5. Masukkan lagi 1 buah Form (Form3) ke dalam Project anda dan tambahkan 1 buah DriveListBox, 1 buah DirListBox, dan 2 buah CommandButton. Atur Seperti gambar di bawah ini:




Ubah Caption Command1 = Add dan Caption Command2 = Cancel

6. Ubah Properties dari Form1, Form2 & Form3
a. Form1
Caption = Mp3 Player
StartUpPosition = 2-Center Screen
b. Form2
Caption = Add File
StartUpPosition = 2-Center Screen
c. Form3
Caption = Add Foler
StartUpPosition = 2-Center Screen

7. Kode/ Listing Form1

Private Sub Command1_Click()
MediaPlayer1.Open List2
End Sub

Private Sub Command2_Click()
MediaPlayer1.Stop
End Sub

Private Sub Command3_Click()
If MediaPlayer1.IsDurationValid = False Then Exit Sub
If Command3.Caption = "Pause" Then
MediaPlayer1.Pause
Command3.Caption = "Resume"
Else
MediaPlayer1.Play
Command3.Caption = "Pause"
End If
End Sub

Private Sub Command4_Click()
Form2.Show
End Sub

Private Sub Command5_Click()
Form3.Show
End Sub

Private Sub List1_Click()
List2.ListIndex = List1.ListIndex
End Sub

Private Sub List1_DblClick()
Command1_Click
End Sub

8. Kode/ Listing Form2
Private Sub Command1_Click()
Form1.List1.AddItem File1
Form1.List2.AddItem Dir1.Path & "\" & File1
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1
End Sub

Private Sub File1_DblClick()
Form1.List1.AddItem File1
Form1.List2.AddItem Dir1.Path & "\" & File1
End Sub
9. Kode/Listing Form3
Private Sub Command1_Click()
Dim a As Long
Dim b As String
If File1.ListCount = "0" Then Exit Sub: MsgBox "No files"
For a& = 0 To File1.ListCount - 1
Form1.List1.AddItem File1.List(a&)
Form1.List2.AddItem Dir1.Path & "\" & File1.List(a&)
Next a
Unload Me
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1
End Sub

8. Test program (tekan F5)

9. Selamat ya... anda sudah berhasil membuat Mp3 player sendiri.

3 komentar:

  1. gan kok pas ane coba error mulu yah?

    BalasHapus
  2. Sebelumnya terima kasih ya udah mau mampir di blog ini, oh iya yang error di kode yang mana ya? atau kira-kira pesan error yang muncul apa ya? ... coba perhatikan lagi bagian List1 dan List2 harus overlapping... ^_^

    BalasHapus
  3. saya masih ga ngerti gan ubah pattern di file listbox nya, setau ane kalo mau ubah nambahin ekstensi file, ya ke common dialog

    BalasHapus