home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 2 / WIN95_2.bin / utils / envelop / envelop.6 / Tools / Bootcamp / basic / apisound / apisound.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  3.7 KB  |  141 lines

  1. Type APISoundMasterForm From SampleMasterForm
  2.   Dim Label1 As New Label
  3.   Dim optReville As New OptionButton
  4.   Dim optDestruct As New OptionButton
  5.   Dim optThatsAll As New OptionButton
  6.   Dim SoundFile As String
  7.   Dim btnPlay As New Button
  8.  
  9.   ' METHODS for object: APISoundMasterForm
  10.   Sub optReville_Click()
  11.     SoundFile = "reville.wav"
  12.   End Sub
  13.  
  14.   Sub optDestruct_Click()
  15.     SoundFile = "destruct.wav"
  16.   End Sub
  17.  
  18.   Sub optThatsAll_Click()
  19.     SoundFile = "thatsall.wav"
  20.   End Sub
  21.  
  22.   Sub ResetApplication_Click ()
  23.   
  24.     ' Initialize Sound Demonstration
  25.     optReville.Value = False
  26.     optDestruct.Value = False
  27.     optThatsAll.Value = False
  28.   
  29.     ' Initilize the sound file variable
  30.     SoundFile = ""
  31.   
  32.   End Sub
  33.  
  34.   Sub btnPlay_Click()
  35.     Dim option As long
  36.     Dim result As long
  37.     Dim sound_file As String
  38.   
  39.     ' Display system busy signal
  40.     App.ShowBusySignal
  41.   
  42.     ' Set a variable to be the name of sound file including absolute path
  43.     sound_file = APISoundMasterForm.SoundFile
  44.   
  45.     If sound_file == "" Then 
  46.       InfoBox.Message("Warning", "No sound option has been selected.")
  47.       Exit Sub
  48.     Else 
  49.       sound_file = SampleDir & sound_file
  50.     End If
  51.   
  52.     ' Play the selected sound file
  53.     result = AudioPlayer.sndPlaySoundA(sound_file, option)
  54.   End Sub
  55.  
  56.   Sub Load()
  57.     ' Restore prerequisite objects that are shared with other
  58.     ' samples, and therefore may already be loaded.
  59.     If FindObject("AudioPlayer") == Nothing Then 
  60.       LoadTextObject(SampleDir & "audio.eto")
  61.     End If
  62.   
  63.   End Sub
  64.  
  65. End Type
  66.  
  67. Type AudioPlayer
  68.   Dim SND_SYNC As Long
  69.   Dim SND_ASYNC As Long
  70.   Dim SND_NODEFAULT As Long
  71.   Dim SND_MEMORY As Long
  72.   Dim SND_LOOP As Long
  73.   Dim SND_NOSTOP As Long
  74.   Declare Function sndPlaySoundA Lib "Winmm" (ByVal file As String, ByVal opt As Long) As Long
  75.  
  76.  
  77.   ' METHODS for object: AudioPlayer
  78.   Function Play(file As String) As Long
  79.     Play = sndPlaySoundA(file, SND_ASYNC Or SND_NODEFAULT)
  80.   End Function
  81.  
  82.   Function PlaySync(file As String) As Long
  83.     Play = sndPlaySoundA(file, SND_SYNC Or SND_NODEFAULT)
  84.   End Function
  85.  
  86. End Type
  87.  
  88. Begin Code
  89. ' Reconstruction commands for object: APISoundMasterForm
  90. '
  91.   With APISoundMasterForm
  92.     .Caption := "Windows Sound Demonstration"
  93.     .Move(4425, 1125, 4890, 3795)
  94.     .DefaultButton := APISoundMasterForm.btnPlay
  95.     .SoundFile := ""
  96.     .SampleDir := "W:\bootcamp\basic\apisound\"
  97.     .SampleName := "apisound"
  98.     With .Label1
  99.       .Caption := "1. Click a sound option, then click Play."
  100.       .ForeColor := 13107200
  101.       .ZOrder := 1
  102.       .Move(300, 300, 4050, 300)
  103.     End With  'APISoundMasterForm.Label1
  104.     With .optReville
  105.       .Caption := "It's time to get up..."
  106.       .ZOrder := 2
  107.       .Move(750, 900, 2400, 300)
  108.       .TabStop := True
  109.       .TabGroup := True
  110.     End With  'APISoundMasterForm.optReville
  111.     With .optDestruct
  112.       .Caption := "This disk will self destruct..."
  113.       .ZOrder := 3
  114.       .Move(750, 1350, 3000, 300)
  115.     End With  'APISoundMasterForm.optDestruct
  116.     With .optThatsAll
  117.       .Caption := "That's all..."
  118.       .ZOrder := 4
  119.       .Move(750, 1800, 2250, 300)
  120.     End With  'APISoundMasterForm.optThatsAll
  121.     With .btnPlay
  122.       .Caption := "Play"
  123.       .ZOrder := 5
  124.       .Move(1500, 2400, 1800, 450)
  125.     End With  'APISoundMasterForm.btnPlay
  126.     With .helpfile
  127.       .FileName := "W:\bootcamp\basic\apisound\apisound.hlp"
  128.     End With  'APISoundMasterForm.helpfile
  129.   End With  'APISoundMasterForm
  130. ' Reconstruction commands for object: AudioPlayer
  131. '
  132.   With AudioPlayer
  133.     .SND_SYNC := 0
  134.     .SND_ASYNC := 1
  135.     .SND_NODEFAULT := 2
  136.     .SND_MEMORY := 4
  137.     .SND_LOOP := 8
  138.     .SND_NOSTOP := 16
  139.   End With  'AudioPlayer
  140. End Code
  141.