home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- BackColor = &H00C0C0C0&
- Caption = "Play Multimedia Files Sample"
- ClientHeight = 555
- ClientLeft = 1530
- ClientTop = 2535
- ClientWidth = 7365
- Height = 1245
- Left = 1470
- LinkTopic = "Form1"
- ScaleHeight = 555
- ScaleWidth = 7365
- Top = 1905
- Width = 7485
- Begin CommandButton cmdPlayAVI
- Caption = "Play AVIVideo"
- Height = 495
- Left = 3720
- TabIndex = 2
- Top = 1440
- Width = 1455
- End
- Begin CommonDialog CMDialog1
- Left = 6240
- Top = 600
- End
- Begin CommandButton cmdGenericPlay
- Caption = "Generic Play"
- Height = 495
- Left = 360
- TabIndex = 0
- Top = 1440
- Width = 1455
- End
- Begin Label Label2
- BackColor = &H00C0C0C0&
- Caption = "Play a WAV file or an AVI file in a default window:"
- Height = 495
- Left = 120
- TabIndex = 3
- Top = 960
- Width = 2295
- End
- Begin Label Label3
- BackColor = &H00C0C0C0&
- Caption = "Play an AVI file in a custom overlapped window:"
- Height = 495
- Left = 3240
- TabIndex = 4
- Top = 960
- Width = 2415
- End
- Begin Label Label1
- BackColor = &H00C0C0C0&
- Caption = "Select Open from the File menu to open a multimedia file."
- Height = 255
- Left = 120
- TabIndex = 1
- Top = 120
- Width = 5415
- End
- Begin Menu mnuFile
- Caption = "&File"
- Begin Menu mnuFile_Open
- Caption = "&Open"
- End
- End
- Begin Menu mnuVBX
- Caption = "MCI.VBX"
- Begin Menu mnuVBX_Standard
- Caption = "Standard Controls..."
- End
- End
- Begin Menu mnuHelp
- Caption = "&Help"
- Begin Menu mnuAbout
- Caption = "&About"
- Shortcut = {F1}
- End
- End
- Sub cmdGenericPlay_Click ()
- Dim ReturnString As String * 1024
- Dim ErrorString As String * 1024
- result& = mciSendString("open " & Filename & " alias file", ReturnString, 1024, 0)
- If Not result& = 0 Then
- errormsg% = mciGetErrorString(result&, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- Exit Sub
- End If
- result& = mciSendString("play file wait", ReturnString, 1024, 0)
- If Not result& = 0 Then
- errormsg% = mciGetErrorString(result&, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- End If
- result& = mciSendString("close file", ReturnString, 1024, 0)
- If Not result& = 0 Then
- errormsg% = mciGetErrorString(result&, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- End If
- End Sub
- Sub cmdmciSendString_Click ()
- Dim ReturnString As String * 1024
- Dim ErrorString As String * 1024
- result& = mciSendString("open " & Filename & " alias file", ReturnString, 1024, 0)
- If Not result& = 0 Then
- errormsg% = mciGetErrorString(result&, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- Exit Sub
- End If
- result& = mciSendString("play file wait", ReturnString, 1024, 0)
- If Not result& = 0 Then
- errormsg% = mciGetErrorString(result&, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- End If
- result& = mciSendString("close file", ReturnString, 1024, 0)
- If Not result& = 0 Then
- errormsg% = mciGetErrorString(result&, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- End If
- End Sub
- Sub cmdPlayAVI_Click ()
- Dim CmdStr As String
- Dim ret As Integer
- Dim ErrorString As String * 1024
- Dim ReturnString As String * 1024
- '*** This will open the AVIVideo and create an overlapped window on the
- '*** form where the video will display. Animation is the device_id.
- CmdStr = ("open " + Filename + " type AVIVideo alias Animation parent " + LTrim$(Str$(Form1.hWnd)) + " style overlapped")
- ret = mciSendString(CmdStr, ReturnString, 1024, 0)
- If Not ret = 0 Then
- errormsg% = mciGetErrorString(ret, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- Exit Sub
- End If
- '*** Put the window near the top left corner of the screen
- ret = mciSendString("put Animation window at 10 10 200 200", ReturnString, 1024, 0)
- If Not ret = 0 Then
- errormsg% = mciGetErrorString(ret, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- End If
- '*** The wait tells the MCI command to complete before returning
- '*** control to the application.
- ret = mciSendString("play Animation wait", ReturnString, 1024, 0)
- If Not ret = 0 Then
- errormsg% = mciGetErrorString(ret, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- End If
- '*** Close windows so they don't crash when you exit the application.
- ret = mciSendString("close Animation", ReturnString, 1024, 0)
- If Not ret = 0 Then
- errormsg% = mciGetErrorString(ret, ErrorString, 1024)
- MsgBox ErrorString, 0, "Error"
- End If
- End Sub
- Sub mnuAbout_Click ()
- frmAbout.Show
- End Sub
- Sub mnuFile_Open_Click ()
- ' Display the File Open... dialog.
- OpenDlg.CMDialog1.FilterIndex = 1
- OpenDlg.CMDialog1.Filter = "AVI Files (*.avi)|*.avi|Wave Files (*.wav)|*.wav|All Files (*.*)|*.*"
- OpenDlg.CMDialog1.Flags = OFN_READONLY Or OFN_FILEMUSTEXIST
- OpenDlg.CMDialog1.CancelError = True
- OpenDlg.CMDialog1.Filename = ""
- On Error Resume Next
- OpenDlg.CMDialog1.Action = 1
- If Err <> 0 Then
- ' No file selected from the "Open File..." dialog.
- Exit Sub
- End If
- 'Assign the selected file to the global variable, Filename
- Filename = OpenDlg.CMDialog1.Filename
- Label1.Caption = Filename
- Form1.Height = 2800
- End Sub
- Sub mnuVBX_Standard_Click ()
- frmMCIVBX.Show 1
- End Sub
-