| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 930 人关注过本帖
标题:Visual Basic 6.0中实现视频画中画
只看楼主 加入收藏
Lieo
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-12-10
收藏
 问题点数:0 回复次数:6 
Visual Basic 6.0中实现视频画中画
[UseMoney=50]

Visual Basic 6.0中实现视频画中画

在VISUAL BAISC 5.0中可以使用播放视频动画文件(*.AVI)的方法在我们的软件中加入动画效果,但在软件中如何实现视频画中画的效果呢?经笔者摸索,发现利用WIDOWS 95的API函数mciExecute、mciSendString和SetWindowPos可实现这一效果。

下面笔者以最常用的大画面中叠加小画面为例来说明视频画中画的实现方法。

一、建立窗体。进入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中运行通过。

[/UseMoney]

[此贴子已经被作者于2004-12-10 10:49:53编辑过]

搜索更多相关主题的帖子: 画中画 Basic 视频 Visual 
2004-12-10 10:44
baren
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-12-19
收藏
得分:0 
2004-12-19 20:43
醉蝶
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2004-12-23
收藏
得分:0 
什么跟什么呀
2004-12-23 17:10
─━☆vb打渔者
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2004-10-31
收藏
得分:0 
大致什么内容?????????

2005-01-01 22:59
access
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-3-18
收藏
得分:0 
还得花积分。不看了!!!
2005-03-19 15:28
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 

真的很黑,很老的文章吧,我公布一下,哈哈! Visual Basic 6.0中实现视频画中画

在VISUAL BAISC 5.0中可以使用播放视频动画文件(*.AVI)的方法在我们的软件中加入动画效果,但在软件中如何实现视频画中画的效果呢?经笔者摸索,发现利用WIDOWS 95的API函数mciExecute、mciSendString和SetWindowPos可实现这一效果。

下面笔者以最常用的大画面中叠加小画面为例来说明视频画中画的实现方法。

一、建立窗体。进入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中运行通过。


天津网站建设 http://www./
2005-03-19 15:34
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
收藏
得分:0 
这就叫画中画了?代码太长了,不如这样做:添加两个 Windows Media Player 控件,一大一小的,然后播放文件,也可以实现同样的效果!
2005-03-19 15:59
快速回复:Visual Basic 6.0中实现视频画中画
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032806 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved