home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / sound / wave / wsample1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-02-27  |  4.2 KB  |  152 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Wave VBX Action Sample"
  6.    ClientHeight    =   2550
  7.    ClientLeft      =   1650
  8.    ClientTop       =   1920
  9.    ClientWidth     =   4095
  10.    Height          =   3075
  11.    Left            =   1590
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   2550
  14.    ScaleWidth      =   4095
  15.    Top             =   1455
  16.    Width           =   4215
  17.    Begin TextBox txtFileLength 
  18.       Height          =   285
  19.       Left            =   240
  20.       TabIndex        =   6
  21.       Top             =   1200
  22.       Width           =   3615
  23.    End
  24.    Begin MabryWave Wave1 
  25.       Exclusive       =   0   'False
  26.       FileLength      =   -1
  27.       Filename        =   ""
  28.       Left            =   3480
  29.       Loop            =   0   'False
  30.       PlayEnd         =   -1
  31.       PlayStart       =   -1
  32.       Top             =   0
  33.    End
  34.    Begin TextBox txtFilename 
  35.       Height          =   285
  36.       Left            =   240
  37.       TabIndex        =   3
  38.       Text            =   "C:\WINDOWS\RINGOUT.WAV"
  39.       Top             =   480
  40.       Width           =   3615
  41.    End
  42.    Begin CommandButton btnStop 
  43.       Caption         =   "Stop"
  44.       Height          =   615
  45.       Left            =   2640
  46.       TabIndex        =   2
  47.       Top             =   1680
  48.       Width           =   1215
  49.    End
  50.    Begin CommandButton btnPause 
  51.       Caption         =   "Resume"
  52.       Height          =   615
  53.       Left            =   1440
  54.       TabIndex        =   1
  55.       Top             =   1680
  56.       Width           =   1215
  57.    End
  58.    Begin CommandButton btnPlay 
  59.       Caption         =   "Play"
  60.       Height          =   615
  61.       Left            =   240
  62.       TabIndex        =   0
  63.       Top             =   1680
  64.       Width           =   1215
  65.    End
  66.    Begin Label Label2 
  67.       BackColor       =   &H00C0C0C0&
  68.       Caption         =   "File Length:"
  69.       Height          =   255
  70.       Left            =   240
  71.       TabIndex        =   5
  72.       Top             =   960
  73.       Width           =   2415
  74.    End
  75.    Begin Label Label1 
  76.       BackColor       =   &H00C0C0C0&
  77.       Caption         =   "Filename:"
  78.       Height          =   255
  79.       Left            =   240
  80.       TabIndex        =   4
  81.       Top             =   240
  82.       Width           =   1935
  83.    End
  84. Option Explicit
  85. Dim fChanged As Integer ' flag: has filename changed?
  86. Sub btnPause_Click ()
  87.     ' if the user wants to pause
  88.     If btnPause.Caption = "Pause" Then
  89.         ' pause
  90.         Wave1.Action = 2
  91.     Else
  92.         ' resume
  93.         Wave1.Action = 3
  94.     End If
  95.     EnableButtons
  96. End Sub
  97. Sub btnPlay_Click ()
  98.     ' make sure the filename is up to date
  99.     SetFilename
  100.     ' play the file
  101.     Wave1.Action = 1
  102.     EnableButtons
  103. End Sub
  104. Sub btnStop_Click ()
  105.     ' stop playing
  106.     Wave1.Action = 4
  107.     ' update buttons
  108.     EnableButtons
  109. End Sub
  110. Sub EnableButtons ()
  111.     Select Case Wave1.Status
  112.         Case 1: ' playing
  113.             If btnPause.Caption <> "Pause" Then
  114.                 btnPause.Caption = "Pause"
  115.             End If
  116.             btnStop.Enabled = True
  117.             btnPause.Enabled = True
  118.         Case 2: ' paused
  119.             If btnPause.Caption <> "Resume" Then
  120.                 btnPause.Caption = "Resume"
  121.             End If
  122.             btnStop.Enabled = True
  123.             btnPause.Enabled = True
  124.         Case 4: ' stopped
  125.             If btnPause.Caption <> "Pause" Then
  126.                 btnPause.Caption = "Pause"
  127.             End If
  128.             btnStop.Enabled = False
  129.             btnPause.Enabled = False
  130.     End Select
  131. End Sub
  132. Sub Form_Load ()
  133.     fChanged = True
  134.     EnableButtons
  135. End Sub
  136. Sub SetFilename ()
  137.     ' if the filename has changed, tell Wave VBX
  138.     If fChanged Then
  139.         ' changed no more
  140.         fChanged = False
  141.         Wave1.Filename = txtFilename
  142.         ' set the file length field
  143.         txtFileLength = Format(Wave1.FileLength / 1000, "0.000") & " seconds"
  144.     End If
  145. End Sub
  146. Sub txtFilename_Change ()
  147.     fChanged = True
  148. End Sub
  149. Sub Wave1_PlayDone ()
  150.     EnableButtons
  151. End Sub
  152.