`
幽灵猫
  • 浏览: 14068 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

如何在WPF应用程序中使用TVideoGrabber

阅读更多

   要在WPF 中使用 TVideoGrabber 组件,需要像下面的方法来使用 VS.NET(DLL) 版本的组件:

——复制TVideoGrabber_x.x.x.x_x86.dll到c:/windows/syswow64 (1)

——复制TVideoGrabber_x.x.x.x_x64.dll到c:/windows/system32 (1)

——根据你使用的VS版本来添加VideoGrabberNETx.x引用到你的application (2)

  1. 这个复制只是开发平台的需要,要发布应用程序的话,你需要分发在你application .EXE的同一文件夹中的x86 和x64 DLLs。
  2. 这个TVideoGrabber WPF组件需要Visual Studio 2010 (NET4.0),Visual Studio 2012 (NET 4.5) 或是更高的版本。

C#应用程序

    通过假设里面视频将会以 “image1”命名显示的WPF控件,如下实例化一个VideoGrabberWPF的实例并连接OnFrameRefresh事件:

using VidGrabNoForm;
namespace WpfApplication1
public partial class MainWindow : Window
VideoGrabberWPF Vg;
public MainWindow()
InitializeComponent();
image1.Stretch = Stretch.UniformToFill;
Vg = new VideoGrabberWPF();
Vg.OnFrameRefresh += new VideoGrabberWPF.On_WPF_FrameRefreshHandler(Vg_OnFrameRefresh);
void Vg_OnFrameRefresh(object sender, VideoGrabberWPF.TOn_WPF_FrameRefreshArgs e)
image1.Source = e.BitmapSource;

 

VB应用程序

    通过假设里面视频将会以 “image1”命名显示的WPF控件,如下实例化一个VideoGrabberWPF的实例并连接OnFrameRefresh事件:

Class Window1
Public Vg As VideoGrabberWPF
Public Sub New()
InitializeComponent()
image1.Stretch = Stretch.UniformToFill
Vg = New VideoGrabberWPF()
AddHandler Me.Vg.OnFrameRefresh, New VideoGrabberWPF.On_WPF_FrameRefreshHandler(AddressOf Vg_OnFrameRefresh)
End Sub
Private Sub Vg_OnFrameRefresh(ByVal sender As Object, ByVal e As VideoGrabberWPF.TOn_WPF_FrameRefreshArgs)
image1.Source = e.BitmapSource
End Sub

    然后你就可以开始预览、录像、回放或重新编码,并使用在MainDemo项目中以同样方式显示的事件,除了在WPF控件中出现的视频。比如:

Vg.PlayerFileName = "myclip.wmv"

Vg.OpenPlayer()

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics