Visual Basic 5.0中实现视频画中画
2008-02-23 06:53:51来源:互联网 阅读 ()
下面笔者以最常用的大画面中叠加小画面为例来说明视频画中画的实现方法。
一、建立窗体。进入VISUAL BAISC 5.0系统环境,建立一个新的窗体FORM1。
二、建立视频窗口。在这里笔者使用了一大一小的两个图画框(PictureBox)作为视频窗口。选择控件工具箱中的PictureBox控件,在窗体中拉出两个方框(Picture1和Picture2)。其中Picture1为大画面,播放AVI01.AVI文件;Picture2为小画面,播放AVI02.AVI文件。
三、编写相应控件的脚本。
通用模块:
Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String,ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
FORM1的ACTIVATE过程:
Dim AA As Long
Dim PlayAvi As Long
Dim tmpVal As String
Dim KeyValSize As Long
On Error Resume Next
tmpVal = String$(1024, 0)
KeyValSize = 1024
PlayAvi = mciSendString("STATUS AVI01 READY" Str(Picture2.hwnd),tmpVal, KeyValSize, 0)
If PlayAvi <> 263 Then
PlayAvi = mciExecute("close AVI01")
End If
tmpVal = String$(1024, 0)
KeyValSize = 1024
PlayAvi = mciSendString("OPEN AVI01.AVI ALIAS AVI01 TYPE AVIVIDEO STYLE CHILD PARENT " Str(Picture2.hwnd) " WAIT", tmpVal, KeyValSize, 0)
x1Pos = Picture1.Width
y1Pos = Picture1.Height
tmpVal = String$(1024, 0)
KeyValSize = 1024
AA = mciSendString("STATUS AVI01 WINDOW HANDLE WAIT", tmpVal, KeyValSize, 0)
If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then
tmpVal = Left(tmpVal, KeyValSize - 1)
Else
tmpVal = Left(tmpVal, KeyValSize)
End If
AA = SetWindowPos(tmpVal, 0, 0, 0, x1Pos, y1Pos, 0)
AA = mciExecute("WINDOW AVI01 STATE SHOW")
tmpVal = String$(1024, 0)
KeyValSize = 1024
PlayAvi = mciSendString("STATUS AVI02 READY" Str(Picture1.hwnd), tmpVal, KeyValSize, 0)
If PlayAvi <> 263 Then
PlayAvi = mciExecute("CLOSE AVI02")
End If
tmpVal = String$(1024, 0)
KeyValSize = 1024
PlayAvi = mciSendString("OPEN AVI02.AVI ALIAS AVI02 TYPE AVIVIDEO STYLE CHILD PARENT " Str(Picture1.hwnd) " WAIT", tmpVal, KeyValSize, 0)
x1Pos = Picture2.Width
y1Pos = Picture2.Height
tmpVal = String$(1024, 0)
KeyValSize = 1024
AA = mciSendString("STATUS AVI02 WINDOW HANDLE WAIT", tmpVal, KeyValSize, 0)
If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then
tmpVal = Left(tmpVal, KeyValSize - 1)
Else
tmpVal = Left(tmpVal, KeyValSize)
End If
AA = SetWindowPos(tmpVal, 0, 0, 0, x1Pos, y1Pos, 0)
MciExecute "WINDOW AVI02 STATE SHOW"
MciExecute "PLAY AVI01 REPEAT"
MciExecute "PLAY AVI02 REPEAT"
On Error GoTo 0
FORM1的QueryUnload过程:
mciExecute "STOP AVI01"
mciExecute "STOP AVI02"
mciExecute "CLOSE AVI01"
mciExecute "CLOSE AVI02"
运行此程序可见两个动画同时播放,实现了视频画中画的效果。以上程序在VISUAL BAISC 5.0及Windows 95中运行通过。
上一篇: Visual Basic 5.0多媒体创作技巧
下一篇: 取得 WAV 文件信息
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash