简体   繁体   English

使用 Vlc.DotNet 将 vlc 添加到我的 WPF 项目时出现问题

[英]Problem adding vlc to my WPF project using Vlc.DotNet

I want to integrate the vlc player to my project in order to display the stream of an IP camera.我想将 vlc 播放器集成到我的项目中,以显示 IP 相机的 stream。 I was following this Integrate VLC player in C# (WPF) project using Vlc.DotNet to make a demo.我正在使用 Vlc.DotNet 在 C# (WPF) 项目中关注这个集成 VLC 播放器进行演示。 Here is my c# code:这是我的 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"));
        }
    }
}

I do the same, but an error appears: VlcControl does not contain a definition for "MediaPlayer"... And its true, the class VlcControl doesn contain it.我也这样做,但出现错误:VlcControl 不包含“MediaPlayer”的定义......确实如此,class VlcControl 不包含它。 The question is if I adding the wrong package (Vlc.DotNet.wpf by ZeBobo5 added with NuGet) or there is another way to integrate the vlc player with this library.问题是我是否添加了错误的 package(Vlc.DotNet.wpf by ZeBobo5 添加了 NuGet)或者还有另一种方法可以将 vlc 播放器与此库集成。 If you know about an example or a guide it would be magnificient.如果您知道示例或指南,那将是非常棒的。

Thank you a lot.十分感谢。

you have an help WIKI for VLC , at the bottom of the web page you have all information about wpf with a sample.你有一个VLC 的帮助 WIKI ,在 web 页面的底部你有关于 wpf 的所有信息和一个样本。

in wpf:在 wpf 中:

<Vlc:VlcControl xmlns:Vlc="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf" x:Name="MyControl" />

In your view constructor, after the call to InitializeComponent()在您的视图构造函数中,调用 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");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM