home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / VISBASIC / WAVE / SAMPLE.ZIP / WSAMPLE1.FRM next >
Text File  |  1995-01-01  |  4KB  |  173 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          =   2955
  11.    Left            =   1590
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   2550
  14.    ScaleWidth      =   4095
  15.    Top             =   1575
  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.       Loop            =   0   'False
  31.       PlayEnd         =   -1
  32.       PlayStart       =   -1
  33.       Top             =   0
  34.    End
  35.    Begin TextBox txtFilename 
  36.       Height          =   285
  37.       Left            =   240
  38.       TabIndex        =   3
  39.       Text            =   "C:\WINDOWS\RINGOUT.WAV"
  40.       Top             =   480
  41.       Width           =   3615
  42.    End
  43.    Begin CommandButton btnStop 
  44.       Caption         =   "Stop"
  45.       Height          =   615
  46.       Left            =   2640
  47.       TabIndex        =   2
  48.       Top             =   1680
  49.       Width           =   1215
  50.    End
  51.    Begin CommandButton btnPause 
  52.       Caption         =   "Resume"
  53.       Height          =   615
  54.       Left            =   1440
  55.       TabIndex        =   1
  56.       Top             =   1680
  57.       Width           =   1215
  58.    End
  59.    Begin CommandButton btnPlay 
  60.       Caption         =   "Play"
  61.       Height          =   615
  62.       Left            =   240
  63.       TabIndex        =   0
  64.       Top             =   1680
  65.       Width           =   1215
  66.    End
  67.    Begin Label Label2 
  68.       BackColor       =   &H00C0C0C0&
  69.       Caption         =   "File Length:"
  70.       Height          =   255
  71.       Left            =   240
  72.       TabIndex        =   5
  73.       Top             =   960
  74.       Width           =   2415
  75.    End
  76.    Begin Label Label1 
  77.       BackColor       =   &H00C0C0C0&
  78.       Caption         =   "Filename:"
  79.       Height          =   255
  80.       Left            =   240
  81.       TabIndex        =   4
  82.       Top             =   240
  83.       Width           =   1935
  84.    End
  85. End
  86. Option Explicit
  87.  
  88. Dim fChanged As Integer ' flag: has filename changed?
  89.  
  90. Sub btnPause_Click ()
  91.     ' if the user wants to pause
  92.     If btnPause.Caption = "Pause" Then
  93.         ' pause
  94.         Wave1.Action = 2
  95.     Else
  96.         ' resume
  97.         Wave1.Action = 3
  98.     End If
  99.  
  100.     EnableButtons
  101. End Sub
  102.  
  103. Sub btnPlay_Click ()
  104.     ' make sure the filename is up to date
  105.     SetFilename
  106.  
  107.     ' play the file
  108.     Wave1.Action = 1
  109.     EnableButtons
  110. End Sub
  111.  
  112. Sub btnStop_Click ()
  113.     ' stop playing
  114.     Wave1.Action = 4
  115.  
  116.     ' update buttons
  117.     EnableButtons
  118. End Sub
  119.  
  120. Sub EnableButtons ()
  121.     Select Case Wave1.Status
  122.         Case 1: ' playing
  123.             If btnPause.Caption <> "Pause" Then
  124.                 btnPause.Caption = "Pause"
  125.             End If
  126.  
  127.             btnStop.Enabled = True
  128.             btnPause.Enabled = True
  129.  
  130.         Case 2: ' paused
  131.             If btnPause.Caption <> "Resume" Then
  132.                 btnPause.Caption = "Resume"
  133.             End If
  134.  
  135.             btnStop.Enabled = True
  136.             btnPause.Enabled = True
  137.  
  138.         Case 4: ' stopped
  139.             If btnPause.Caption <> "Pause" Then
  140.                 btnPause.Caption = "Pause"
  141.             End If
  142.  
  143.             btnStop.Enabled = False
  144.             btnPause.Enabled = False
  145.     End Select
  146. End Sub
  147.  
  148. Sub Form_Load ()
  149.     fChanged = True
  150.     EnableButtons
  151. End Sub
  152.  
  153. Sub SetFilename ()
  154.     ' if the filename has changed, tell Wave VBX
  155.     If fChanged Then
  156.         ' changed no more
  157.         fChanged = False
  158.         Wave1.Filename = txtFilename
  159.  
  160.         ' set the file length field
  161.         txtFileLength = Format(Wave1.FileLength / 1000, "0.000") & " seconds"
  162.     End If
  163. End Sub
  164.  
  165. Sub txtFilename_Change ()
  166.     fChanged = True
  167. End Sub
  168.  
  169. Sub Wave1_PlayDone ()
  170.     EnableButtons
  171. End Sub
  172.  
  173.