[英]Play video from stream using Vlc.Dotnet for WPF
我希望WPF應用程序播放給定流中的視頻。 嘗試使用google,但找不到最新的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 Player中可以正常工作。 我在這里有什么選擇?
提前致謝。
這應該使您開始:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.