【问题标题】:Play video from stream using Vlc.Dotnet for WPF使用 Vlc.Dotnet for WPF 从流中播放视频
【发布时间】:2018-10-29 10:21:06
【问题描述】:

我希望我的 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 Player 中运行良好。我在这里有什么选择?

提前致谢。

【问题讨论】:

    标签: c# wpf libvlc vlc.dotnet


    【解决方案1】:

    这应该让你开始:

    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

    【讨论】:

    • 当我尝试写 this.VlcControl.SourceProvider 时,我找不到我的 Vlc 播放器的任何 SourceProvider 属性。我已经使用 NuGet 安装了最新版本 (3.0.4)。
    • 用样本克隆 repo 并从那里开始。查看与您的代码的差异。检查using 语句
    • 原来SourceProvider 仅在预览版 3.0 中可用。所以只好下载预发布版本。
    猜你喜欢
    • 2012-07-20
    • 2017-04-02
    • 2020-11-13
    • 1970-01-01
    • 2023-01-04
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多