home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / mabry / wave10 / sample / wsample3.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-01-01  |  4.7 KB  |  176 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Wave VBX Start/End Sample"
  6.    ClientHeight    =   3135
  7.    ClientLeft      =   1650
  8.    ClientTop       =   1920
  9.    ClientWidth     =   4095
  10.    Height          =   3540
  11.    Left            =   1590
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3135
  14.    ScaleWidth      =   4095
  15.    Top             =   1575
  16.    Width           =   4215
  17.    Begin Timer Timer1 
  18.       Interval        =   50
  19.       Left            =   3000
  20.       Top             =   0
  21.    End
  22.    Begin TextBox txtPosition 
  23.       Height          =   285
  24.       Left            =   240
  25.       TabIndex        =   9
  26.       Top             =   1200
  27.       Width           =   3615
  28.    End
  29.    Begin TextBox txtEnd 
  30.       Height          =   285
  31.       Left            =   2160
  32.       TabIndex        =   7
  33.       Top             =   1800
  34.       Width           =   1695
  35.    End
  36.    Begin TextBox txtStart 
  37.       Height          =   285
  38.       Left            =   240
  39.       TabIndex        =   5
  40.       Top             =   1800
  41.       Width           =   1695
  42.    End
  43.    Begin MabryWave Wave1 
  44.       Exclusive       =   0   'False
  45.       FileLength      =   -1
  46.       Filename        =   ""
  47.       Left            =   3480
  48.       Loop            =   0   'False
  49.       LoopCount       =   0   'False
  50.       PlayEnd         =   -1
  51.       PlayStart       =   -1
  52.       Top             =   0
  53.    End
  54.    Begin TextBox txtFilename 
  55.       Height          =   285
  56.       Left            =   240
  57.       TabIndex        =   2
  58.       Text            =   "C:\WINDOWS\RINGOUT.WAV"
  59.       Top             =   480
  60.       Width           =   3615
  61.    End
  62.    Begin CommandButton btnStop 
  63.       Caption         =   "Stop"
  64.       Height          =   615
  65.       Left            =   2040
  66.       TabIndex        =   1
  67.       Top             =   2280
  68.       Width           =   1815
  69.    End
  70.    Begin CommandButton btnPlay 
  71.       Caption         =   "Play"
  72.       Height          =   615
  73.       Left            =   240
  74.       TabIndex        =   0
  75.       Top             =   2280
  76.       Width           =   1815
  77.    End
  78.    Begin Label Label4 
  79.       BackColor       =   &H00C0C0C0&
  80.       Caption         =   "Position:"
  81.       Height          =   255
  82.       Left            =   240
  83.       TabIndex        =   8
  84.       Top             =   960
  85.       Width           =   1215
  86.    End
  87.    Begin Label Label3 
  88.       BackColor       =   &H00C0C0C0&
  89.       Caption         =   "End:"
  90.       Height          =   255
  91.       Left            =   2160
  92.       TabIndex        =   6
  93.       Top             =   1560
  94.       Width           =   1215
  95.    End
  96.    Begin Label Label2 
  97.       BackColor       =   &H00C0C0C0&
  98.       Caption         =   "Start:"
  99.       Height          =   255
  100.       Left            =   240
  101.       TabIndex        =   4
  102.       Top             =   1560
  103.       Width           =   1215
  104.    End
  105.    Begin Label Label1 
  106.       BackColor       =   &H00C0C0C0&
  107.       Caption         =   "Filename:"
  108.       Height          =   255
  109.       Left            =   240
  110.       TabIndex        =   3
  111.       Top             =   240
  112.       Width           =   1935
  113.    End
  114. Option Explicit
  115. Dim fChanged As Integer ' flag: has filename changed?
  116. Sub btnPlay_Click ()
  117.     ' make sure the filename is up to date
  118.     SetFilename
  119.     ' check for start field
  120.     If Trim(txtStart) <> "" Then
  121.         Wave1.PlayStart = Val(txtStart)
  122.     Else
  123.         Wave1.PlayStart = -1
  124.     End If
  125.     ' check for end field
  126.     If Trim(txtEnd) <> "" Then
  127.         Wave1.PlayEnd = Val(txtEnd)
  128.     Else
  129.         Wave1.PlayEnd = -1
  130.     End If
  131.     ' play the file
  132.     Wave1.Action = 1
  133.     EnableButtons
  134. End Sub
  135. Sub btnStop_Click ()
  136.     ' stop playing
  137.     Wave1.Action = 4
  138.     ' update buttons
  139.     EnableButtons
  140. End Sub
  141. Sub EnableButtons ()
  142.     Select Case Wave1.Status
  143.         Case 1: ' playing
  144.             btnStop.Enabled = True
  145.         Case 2: ' paused
  146.             btnStop.Enabled = True
  147.         Case 4: ' stopped
  148.             btnStop.Enabled = False
  149.     End Select
  150. End Sub
  151. Sub Form_Load ()
  152.     fChanged = True
  153.     EnableButtons
  154. End Sub
  155. Sub SetFilename ()
  156.     ' if the filename has changed, tell Wave VBX
  157.     If fChanged Then
  158.         ' changed no more
  159.         fChanged = False
  160.         Wave1.Filename = txtFilename
  161.     End If
  162. End Sub
  163. Sub Timer1_Timer ()
  164.     If Wave1.Position = -1 Then
  165.         txtPosition = ""
  166.     Else
  167.         txtPosition = Format(Wave1.Position / 1000, "0.000") & " seconds"
  168.     End If
  169. End Sub
  170. Sub txtFilename_Change ()
  171.     fChanged = True
  172. End Sub
  173. Sub Wave1_PlayDone ()
  174.     EnableButtons
  175. End Sub
  176.