我想将vlc播放器集成到我的项目中,以便显示IP摄像机的流媒体。我是按照以下的方法来做的 在C#(WPF)项目中使用Vlc.DotNet集成VLC播放器。 来做一个演示。这是我的c#代码。
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Vlc.DotNet.Wpf;
namespace RTSPyVLC
{
/// <summary>
/// Lógica de interacción para MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
vlcPlayer.MediaPlayer.VlcLibDirectory =
//replace this path with an appropriate one
new DirectoryInfo(@"c:\Program Files (x86)\VideoLAN\VLC\");
vlcPlayer.MediaPlayer.EndInit();
vlcPlayer.MediaPlayer.Play(new Uri("http://download.blender.org/peach/" +
"bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"));
}
}
}
我也是这么做的,但是出现了一个错误: VlcControl不包含 "MediaPlayer "的定义......这是真的,VlcControl类不包含它。问题是我是否添加了错误的包(Vlc.DotNet.wpf由ZeBobo5用NuGet添加)或者有其他方法将vlc播放器与该库集成。如果你知道一个例子或指南,这将是巨大的。
非常感谢你。
你有一个帮助 VLC的WIKI在网页的底部,你有关于wpf的所有信息与样本。
在wpf中。
<Vlc:VlcControl xmlns:Vlc="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf" x:Name="MyControl" />
在你的视图构造函数中,在调用InitializeComponent()之后。
var vlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
var options = new string[]
{
// VLC options can be given here. Please refer to the VLC command line documentation.
};
this.MyControl.SourceProvider.CreatePlayer(vlcLibDirectory, options);
// Load libvlc libraries and initializes stuff. It is important that the options (if you want to pass any) and lib directory are given before calling this method.
this.MyControl.SourceProvider.MediaPlayer.Play("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov");