using System.ComponentModel; using System.Data.Common; using System.IO; using System.Reflection; using System.Windows; using System.Windows.Controls; using Vlc.DotNet.Wpf; namespace TV_Player { public partial class MainWindow : Window { private readonly DirectoryInfo vlcLibDirectory; private VlcControl control; public MainWindow() { InitializeComponent(); var currentAssembly = Assembly.GetEntryAssembly(); var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName; // Default installation path of VideoLAN.LibVLC.Windows vlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); this.control = new VlcControl(); this.control.SourceProvider.CreatePlayer(vlcLibDirectory/* pass your player parameters here */); Initialize(); } protected override void OnClosing(CancelEventArgs e) { this.control?.Dispose(); base.OnClosing(e); } private void OnPlayButtonClick(object sender, RoutedEventArgs e) { //this.control?.Dispose(); //this.control = new VlcControl(); //this.ControlContainer.Content = this.control; //this.control.SourceProvider.CreatePlayer(this.vlcLibDirectory); // This can also be called before EndInit this.control.SourceProvider.MediaPlayer.Log += (_, args) => { string message = $"libVlc : {args.Level} {args.Message} @ {args.Module}"; System.Diagnostics.Debug.WriteLine(message); }; control.SourceProvider.MediaPlayer.Play(new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi")); } private void OnStopButtonClick(object sender, RoutedEventArgs e) { this.control?.Dispose(); this.control = null; } private void OnForwardButtonClick(object sender, RoutedEventArgs e) { if (this.control == null) { return; } this.control.SourceProvider.MediaPlayer.Rate = 2; } private void GetLength_Click(object sender, RoutedEventArgs e) { if (this.control == null) { return; } //GetLength.Content = this.control.SourceProvider.MediaPlayer.Length + " ms"; } private void GetCurrentTime_Click(object sender, RoutedEventArgs e) { if (this.control == null) { return; } //GetCurrentTime.Content = this.control.SourceProvider.MediaPlayer.Time + " ms"; } private void SetCurrentTime_Click(object sender, RoutedEventArgs e) { if (this.control == null) { return; } this.control.SourceProvider.MediaPlayer.Time = 5000; //SetCurrentTime.Content = this.control.SourceProvider.MediaPlayer.Time + " ms"; } } }