我希望我的WPF应用程序从一个给定的流播放视频。试图谷歌,但没有找到任何工作的例子与最新的Vlc.Dotnet.Wpf版本。我已经用NuGet安装了最新的软件包,到目前为止,我已经安装了如下所示:
我的XAML:
<Vlc:VlcControl xmlns:Vlc="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf" x:Name="vlcPlayer" />C#代码:
vlcPlayer.BeginInit();
vlcPlayer.MediaPlayer.VlcLibDirectory = new DirectoryInfo(@"C:\Program Files (x86)\VideoLAN\VLC\");
vlcPlayer.EndInit();
vlcPlayer.MediaPlayer.Play(new Uri("http://79.170.191.118:1935/formula55_2/stream55_2/playlist.m3u8"));我跑的时候什么都没发生。然而,流在Vlc播放器中工作良好。我在这里有什么选择?
提前谢谢。
发布于 2018-11-03 10:17:14
这应该会让你开始:
public MainWindow()
{
InitializeComponent();
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
// Default installation path of VideoLAN.LibVLC.Windows
var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
this.VlcControl.SourceProvider.CreatePlayer(libDirectory/* pass your player parameters here */);
this.VlcControl.SourceProvider.MediaPlayer.Play(new Uri("http://79.170.191.118:1935/formula55_2/stream55_2/playlist.m3u8"));
}您需要安装https://www.nuget.org/packages/VideoLAN.LibVLC.Windows/,这是在.NET中使用libvlc库的正确方式。
下一次,请张贴一些日志,否则主要是猜测。也可以查看官方的样本https://github.com/ZeBobo5/Vlc.DotNet/tree/develop/src/Samples
https://stackoverflow.com/questions/53043363
复制相似问题