2 trong 1: Play a Wav, Play a mid

Các thủ thuật về âm thanh, đồ họa, truyền thông đa phương tiện...
Post Reply
User avatar
truongphu
VIP
VIP
Posts: 4780
Joined: Sun 04/11/2007 10:57 am
Location: Cam Đức, Khánh hòa
Has thanked: 14 times
Been thanked: 525 times

2 trong 1: Play a Wav, Play a mid

Post by truongphu »

Thủ thuật: 2 trong 1: Play a Wav, Play a mid
Tác giả: Patrick Gillespie, truongphu edit
Mô tả: Chỉ vài dòng code có thể play a mid hay a wav

Code: Select all

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As LongDim ret As Long  'Code by Patrick GillespiePrivate Sub Command1_Click()  ' Open a midi fileret = mciSendString("open C:\Dancing_Queen.Mid type sequencer", 0&, 0, 0)End SubPrivate Sub Command2_Click()  ' Play a midi fileret = mciSendString("play C:\Dancing_Queen.Mid", 0&, 0, 0)End SubPrivate Sub Command3_Click()  ' Stop a midi fileret = mciSendString("stop C:\Dancing_Queen.Mid", 0&, 0, 0)End SubPrivate Sub Command4_Click()  ' Pause a midi fileret = mciSendString("pause C:\Dancing_Queen.Mid", 0&, 0, 0)End SubPrivate Sub Command5_Click()  ' Resume playing a midi fileret = mciSendString("resume C:\Dancing_Queen.Mid", 0&, 0, 0)End SubPrivate Sub Command6_Click()  ' [b]Play a Wav[/b]ret = mciSendString("open C:\parent-teachernite.wav [b]type waveaudio alias theFile[/b]", 0&, 0, 0)End SubPrivate Sub Command7_Click()  ' Close Formret = mciSendString("close C:\Dancing_Queen.Mid", 0&, 0, 0)EndEnd Sub
Ghi chú: chưa test nhiều, nhờ các bạn
o0o--truongphu--o0o

.........
Ghé thăm:
Chuyện Linh Tinh
User avatar
VuVanHoanh
Thành viên danh dự
Thành viên danh dự
Posts: 1259
Joined: Thu 03/06/2010 9:23 pm
Location: Kim Sơn - Đông Triều - Quảng Ninh
Has thanked: 22 times
Been thanked: 138 times
Contact:

Chạy một tệp nhạc không sử dụng OCX

Post by VuVanHoanh »

  1. Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
  2. Private Const SND_ASYNC                         As Long = &H1
  3. Private Const SND_NODEFAULT                     As Long = &H2
  4.  
  5. Public Function PlaySnd(ByVal sFile As String) As String
  6.     sndPlaySound sFile, SND_ASYNC Or SND_NODEFAULT
  7. End Function
Since 2008...
One love! :x
Post Reply

Return to “[VB] Âm thanh và Đồ họa”