Jalankan MP3 tanpa OCX (bag.2)
Pada artilkel sebelumnya, kita telah mendeklarasikan hal-hal yang diperlukan. sekarang ini, masuklah kita kepada menulis fugnsi-fungsi yang diperlukan dan mencegat beberapa event.
Fungsi yang diperlukan adalah:
Public Function MP3Play(wndHandle As Long,
sFileName As String)
Dim cmdToDo As String * 255
Dim dwReturn As Long
Dim ret As String * 128
Dim tmp As String * 255
Dim lenShort As Long
Dim ShortPathAndFie As String, glo_HWND As Long
If Dir(sFileName) = "" Then
mmOpen = "Error with input file"
Exit Function
End If
lenShort = GetShortPathName(sFileName, tmp, 255)
ShortPathAndFie = Left$(tmp, lenShort)
glo_HWND = wndHandle
cmdToDo = "open " & ShortPathAndFie & " type
MPEGVideo Alias MP3Play"
dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
If dwReturn <> 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
mmOpen = ret
MsgBox ret, vbCritical
Exit Function
End If
mmOpen = "Success"
mciSendString "play MP3Play", 0, 0, 0
End Function
Public Function MP3Pause()
mciSendString "pause MP3Play", 0, 0, 0
End Function
Public Function MP3UnPause()
mciSendString "play MP3Play", 0, 0, 0
End Function
Public Function MP3Stop() As String
mciSendString "stop MP3Play", 0, 0, 0
mciSendString "close MP3Play", 0, 0, 0
End Function
Private Sub Open_file()
CommonDialog1.Filter = "MP3 Files *.mp3"
CommonDialog1.ShowOpen
nFileName = CommonDialog1.FileName
Text1.Text = nFileName
MP3Play hWnd, nFileName
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Exit Sub
ex:
Command5.Enabled = True
End Sub
Pemrograman
Public Function IsPlaying() As Boolean
Static s As String * 30
mciSendString "status MP3Play mode", s, Len(s), 0
IsPlaying = (Mid$(s, 1, 7) = "playing")
End Function
4) Sedangkan event-event yang dicegat adalah:
Private Sub Check1_Click()
Timer1 = Not Timer1
If Timer1 Then Check1.Value = 1 Else Check1.
Value = 0
End Sub
Private Sub Command1_Click()
Command1.Enabled = False
Command5.Enabled = False
Open_file
End Sub
Private Sub Command2_Click()
If Command2.Caption = "Pause" Then
Command2.Caption = "Play"
MP3Pause
Else
Command2.Caption = "Pause"
MP3UnPause
End If
End Sub
Private Sub Command3_Click()
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command1.Enabled = True
Command2.Caption = "Pause"
MP3Stop
End Sub
Private Sub Command4_Click()
mciSendString "stop MP3Play", 0, 0, 0
mciSendString "play MP3Play from 0", 0, 0, 0
Command2.Caption = "Pause"
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
MP3Stop
End Sub
5) Simpan, dan jalankan program. Selamat Mencoba....!!
Baca juga artikel menarik ini: Harga Jual Blackberry IPhone Laptop Murah
Blackbery
Iphone
Solusi Forum Komunitas Online Indonesia Thumblr
Spesifikasi iPHONE
HiPhone, hasil Kloningan iPhone
HiPhone dan Smart Phone Cina
Solusi Forum Komunitas Online Indonesia
Produk Unggulan BlackBerry
Model Blackberry
Kontroversi Blackberry
Harga Serba Murah Jual Blackberry IPhone
Harga Serba Murah Jual Blackberry IPhone
Kecil Jadi Kawan, Besar Jadi Lawan
Mohon dukungannya yach....!!
:)
0 komentar to "Jalankan MP3 dengan VB 6.0 (bag.2)"
Pages
Labels :
- Artikel
- Artikel Linux
- bahasa C
- Blogger-Templates-Colorizetemplates.com
- database
- design
- download
- Download Software
- games
- handphone
- Hardware
- image
- Indonesia-Siap-Bersaing-di-SERP
- Informasi gadget
- informasi Handphone
- Informasi Network
- Informasi software
- java script
- matematika
- Multimedia
- PC tool
- Security/Antivirus
- Software Audio/Video
- Software Grapich
- Software Pendidikan
- Software Tools
- Trik Google+
- Tutorial
- utility
- visual basic
Posting Komentar