home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / mswindo / programm / tools / 572 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  2.4 KB

  1. From: galenr@hpgrla.gr.hp.com (Galen Raben)
  2. Date: Tue, 28 Jul 1992 15:28:08 GMT
  3. Subject: Re: VB and sound
  4. Message-ID: <36720005@hpgrla.gr.hp.com>
  5. Organization: Hewlett-Packard, Greeley, CO
  6. Path: sparky!uunet!darwin.sura.net!mips!sdd.hp.com!hplabs!hplextra!hpfcso!hpgrla!galenr
  7. Newsgroups: comp.os.ms-windows.programmer.tools
  8. References: <1992Jul21.223156.21625@cs.brown.edu>
  9. Lines: 66
  10.  
  11. In comp.os.ms-windows.programmer.tools, sp@cs.brown.edu (Seth Padowitz) writes:
  12.  
  13. >If you have Windows 3.1, then you can use the sndPlaySound() API
  14. >from VB to play sounds through your soundblaster.
  15. >Alternatively, you can use the Media Control Interface (MCI)
  16. >Custom Control included in the VB Professional Toolkit to play
  17. >sounds.
  18. [... stuff deleted ...]
  19. >You'll need to create a VB prototype for sndPlaySound().  My VB
  20. >is a bit rusty, so I'll simply recommend that you look at your
  21. >manual.
  22.  
  23. >Hope this helps.
  24.  
  25. >Seth
  26.  
  27. Hi Seth, good to see you again!  I've had some requests for the VB
  28. prototypes as well, so I'll post them here for anyone to use!!!
  29. Note - these are NOT official MS prototypes!  Use them, but at your
  30. own risk... :-)
  31.  
  32. In the global declare....
  33.  
  34. Declare Function sndPlaySound Lib "MMsystem" (ByVal lpSound As String, ByVal Flags As Integer) As Integer
  35.  
  36. Global Const SND_SYNC = 0
  37. Global Const SND_ASYNC = 1
  38.  
  39. In your program simply put...
  40.  
  41. Ret% = SndPlaySound("TADA.WAV", SND_ASYNC)
  42.  
  43.  
  44. You can also access the MCI without the VB Pro Toolkit!!  Much more flexible
  45. but more difficult to use.  You communicate with MCI via messages.  The
  46. alias is arbitrary, the ones I used below are for readability...  A few 
  47. examples should get you going...
  48.  
  49. The VB prototypes are...
  50.  
  51. Declare Function mciSendString Lib "MMsystem" (ByVal lpCoMMand As String, ByVal lpReturnString As String, ByVal WReturnLength As Integer, ByVal hCallback As Integer) As Long
  52.  
  53. Declare Function mciGetErrorString Lib "MMsystem" (ByVa dwError As Long, ByVal lpBuffer As String, ByVal WReturnLength As Integer) As Integer
  54.  
  55. In your program to play TADA.WAV...
  56.  
  57. Ret% = mciSendString("Open TADA.WAV alias TALK");
  58. Ret% = mciSendString("Play TALK");
  59. Ret% = mciSendString("Close TALK");
  60.  
  61. to play "CANYON.MID":
  62.  
  63. Ret% = mciSendString("Open CANYON.MID alias MUSIC");
  64. Ret% = mciSendString("Play MUSIC");
  65. Ret% = micSendString("Close MUSIC");
  66.  
  67. to pause it
  68.  
  69. Ret% = mciSendString("Pause MUSIC");
  70.  
  71. simply "Play MUSIC" to continue.
  72.  
  73. I think you get the idea...
  74. Anyway, enjoy!!!!!
  75. - Galen -
  76.  
  77.