wpf 调用vlc
时间: 2023-08-03 17:05:43 浏览: 119
要在 WPF 应用程序中调用 VLC 播放器,需要使用 libvlc 库和 VLC ActiveX 控件。以下是一些简单的步骤:
1.下载和安装 VLC 播放器。
2.在 Visual Studio 中创建一个新的 WPF 应用程序。
3.在项目中添加对 AxInterop.VLCPlugin 和 Interop.VLCPlugin 的引用。
4.在 MainWindow.xaml 中添加一个 WindowsFormsHost 控件,它将用于承载 VLC ActiveX 控件。
5.在 MainWindow.xaml.cs 中添加以下代码:
```csharp
using System;
using System.Windows;
using System.Windows.Forms.Integration;
namespace WpfVLCPlayer
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowsFormsHost host = new WindowsFormsHost();
AxAXVLC axvlc = new AxAXVLC();
host.Child = axvlc;
grid1.Children.Add(host);
axvlc.CreateControl();
axvlc.Visible = true;
axvlc.Dock = System.Windows.Forms.DockStyle.Fill;
axvlc.playlist.add(@"C:\test.mp4");
axvlc.playlist.play();
}
}
}
```
6.在 axvlc.playlist.add() 方法中指定要播放的视频文件路径。
7.运行应用程序,应该可以看到 VLC 播放器正在播放指定的视频文件。
阅读全文
相关推荐


















