📄 aviplay.frm
字号:
VERSION 5.00
Begin VB.Form frmMain
Caption = "利用Windows API 播放AVI文件"
ClientHeight = 4875
ClientLeft = 60
ClientTop = 345
ClientWidth = 6225
LinkTopic = "Form1"
ScaleHeight = 4875
ScaleWidth = 6225
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdPause
Caption = "暂停"
Height = 495
Left = 3720
TabIndex = 7
Top = 480
Width = 855
End
Begin VB.PictureBox Picture1
Height = 3495
Left = 2160
ScaleHeight = 3435
ScaleWidth = 3795
TabIndex = 6
Top = 1080
Width = 3855
End
Begin VB.CommandButton cmdPlay
Caption = "播放"
Height = 495
Left = 2520
TabIndex = 5
Top = 480
Width = 855
End
Begin VB.CommandButton cmdStop
Caption = "停止"
Height = 495
Left = 5040
TabIndex = 4
Top = 480
Width = 855
End
Begin VB.FileListBox File1
Height = 1710
Left = 240
Pattern = "*.avi"
TabIndex = 2
Top = 2640
Width = 1815
End
Begin VB.DirListBox Dir1
Height = 1560
Left = 240
TabIndex = 1
Top = 960
Width = 1815
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 240
TabIndex = 0
Top = 480
Width = 1815
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "请选择.avi文件"
Height = 180
Left = 120
TabIndex = 3
Top = 120
Width = 1284
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer
Private Sub cmdPause_Click()
If i Mod 2 = 0 Then
mciSendString "pause MyAVI", vbNullString, 0, 0
ElseIf i Mod 2 = 1 Then
mciSendString "play MyAVI", vbNullString, 0, 0
End If
End Sub
Private Sub cmdPlay_Click()
Dim PathName As String, S As String, ShortPathName As String
Dim mciCommand As String
PathName = File1.Path
If Right(PathName, 1) <> "\" Then PathName = PathName & "\"
PathName = PathName & File1.FileName
S = String(LenB(PathName), Chr(0))
GetShortPathName PathName, S, Len(S)
ShortPathName = Left(S, InStr(S, Chr(0)) - 1)
mciSendString "close MyAVI", vbNullString, 0, 0
mciCommand = "open " & ShortPathName & " alias MyAVI" & " parent " & Picture1.hWnd & " style child"
mciSendString mciCommand, vbNullString, 0, 0
With Picture1
.ScaleMode = vbPixels
mciCommand = "put MyAVI window at 0 0 " & _
.ScaleWidth & " " & .ScaleHeight
mciSendString mciCommand, vbNullString, 0, 0
End With
mciSendString "play MyAVI", vbNullString, 0, 0
End Sub
Private Sub cmdStop_Click()
mciSendString "close MyAVI", vbNullString, 0, 0
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Unload(Cancel As Integer)
mciSendString "close MyAVI", vbNullString, 0, 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -