private void MediaPlayer_Playing(object sender, Vlc.DotNet.Core.VlcMediaPlayerPlayingEventArgs e) { //1 is -1 ("disable") and second is whats in the main player for (int i = 2; i < VM.MainSource.MediaPlayer.Video.Tracks.Count; i++) { VlcVideoSourceProvider ctl = CreatePlayer(i); VM.AddVideoSource(ctl); ctl.MediaPlayer.Play(); } _ignoreVolumeValChange = true; Dispatcher.Invoke(() => volumeSlider.Value = VM.MainSource.MediaPlayer.Audio.Volume); _ignoreVolumeValChange = false; if (_pauseOnPlay) { Dispatcher.BeginInvoke(new Action(() => { Pause(this, null); timelineSlider.Value = 0; })); } _pauseOnPlay = false; VM.MainSource.MediaPlayer.Playing -= MediaPlayer_Playing; }
private void InitializeVLCplayer()//Initialize VLC player using sourceprovider { this.sourceProvider = new VlcVideoSourceProvider(this.Dispatcher); var libDirectory = new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); sourceProvider.CreatePlayer(libDirectory, options); }
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.sourceProvider = new VlcVideoSourceProvider(this.Dispatcher); this.sourceProvider.CreatePlayer(libDirectory /* pass your player parameters here */); this.sourceProvider.MediaPlayer.Play(new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi")); this.Video.SetBinding(System.Windows.Controls.Image.SourceProperty, new Binding(nameof(VlcVideoSourceProvider.VideoSource)) { Source = sourceProvider }); this.BackgroundVideo.SetBinding(System.Windows.Controls.Image.SourceProperty, new Binding(nameof(VlcVideoSourceProvider.VideoSource)) { Source = sourceProvider }); }
public PinballFrontEndView() { InitializeComponent(); //Start WPF Components /////////////////////////////////////////////////////////////////////////////////////////////////// // SETUP VLC LIBRARY /////////////////////////////////////////////////////////////////////////////////////////////////// //Create Video Source Provider sourceProvider = new VlcVideoSourceProvider(this.Dispatcher); sourceProvider.CreatePlayer(Model.VlcGlobal.GetVlcLibrary()); sourceProvider.MediaPlayer.Log += ((a, b) => { }); //Do nothing with log sourceProvider.MediaPlayer.Playing += MediaPlayer_Playing; //sourceProvider.MediaPlayer.VideoOutChanged += MediaPlayer_VideoOutChanged; //Bind source provider to image Playfield.SetBinding(Image.SourceProperty, new Binding(nameof(VlcVideoSourceProvider.VideoSource)) { Source = sourceProvider }); /////////////////////////////////////////////////////////////////////////////////////////////////// // SETUP View Model /////////////////////////////////////////////////////////////////////////////////////////////////// viewModel = new PinballFrontEnd.ViewModel.PinballFrontEndViewModel(); this.DataContext = viewModel; viewModel.TableChanged += ViewModel_TableChanged; /////////////////////////////////////////////////////////////////////////////////////////////////// // SETUP Delay Timers /////////////////////////////////////////////////////////////////////////////////////////////////// //Start Video Update Timer vidTimer = new System.Timers.Timer(500); //Delays loading of video to allow fast switching vidTimer.Elapsed += VidTimer_Elapsed; //CurrentSource = new Uri("."); vidTimer.AutoReset = false; vidTimer.Start(); showTimer = new System.Timers.Timer(500); showTimer.Elapsed += ShowTimer_Elapsed; showTimer.AutoReset = false; showTimer.Start(); /////////////////////////////////////////////////////////////////////////////////////////////////// // Other /////////////////////////////////////////////////////////////////////////////////////////////////// //Set to software render //RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; //Prevent the PC from going into sleep mode (keep monitors on) Nutmegz.UnManaged.PowerControl.PreventSleep(); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { var currentAssembly = Assembly.GetEntryAssembly(); var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName; var libDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); //this.vlcControl.SourceProvider.CreatePlayer(libDirectory); //this.vlcControl.SourceProvider.MediaPlayer.Play(new FileInfo(@"D:\迅雷下载\[阳光电影www.ygdy8.net].追龙.HD.720p.国语中字.mkv")); if (vlcVideoSourceProvider == null) { vlcVideoSourceProvider = new VlcVideoSourceProvider(this.Dispatcher); vlcVideoSourceProvider.CreatePlayer(libDirectory); SetBindings(); } }
/// <summary> /// 使用image做载体 /// </summary> private void initImgVlc() { var currentAssembly = Assembly.GetEntryAssembly(); var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName; if (currentDirectory == null) { return; } var VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"vlc\lib")); this.sourceProvider = new VlcVideoSourceProvider(this.Dispatcher); this.sourceProvider.CreatePlayer(VlcLibDirectory /* pass your player parameters here */); }
public MediaView(ViewModel.PinballFrontEndViewModel viewModel) { //this.DataContext = this; InitializeComponent(); this.viewModel = viewModel; this.DataContext = this.viewModel; this.viewModel.TableChanged += ViewModel_TableChanged; /////////////////////////////////////////////////////////////////////////////////////////////////// // SETUP Delay Timers /////////////////////////////////////////////////////////////////////////////////////////////////// //Start Video Update Timer vidTimer = new System.Timers.Timer(500); vidTimer.Elapsed += VidTimer_Elapsed; //CurrentSource = new Uri("."); vidTimer.AutoReset = false; vidTimer.Start(); showTimer = new System.Timers.Timer(500); showTimer.Elapsed += ShowTimer_Elapsed; showTimer.AutoReset = false; showTimer.Start(); // SETUP VLC LIBRARY //Create Video Source Provider sourceProvider = new VlcVideoSourceProvider(this.Dispatcher); sourceProvider.CreatePlayer(Model.VlcGlobal.GetVlcLibrary()); sourceProvider.MediaPlayer.Log += ((a, b) => { }); //Do nothing with log sourceProvider.MediaPlayer.Playing += MediaPlayer_Playing; //Bind source provider to image VideoImage.SetBinding(Image.SourceProperty, new Binding(nameof(VlcVideoSourceProvider.VideoSource)) { Source = sourceProvider }); }
private VlcVideoSourceProvider CreatePlayer(int trackIdx) { VlcVideoSourceProvider ctl = new VlcVideoSourceProvider(Dispatcher); ctl.CreatePlayer(_vlcLibDir); ctl.MediaPlayer.SetMedia(_medialUrl); EventHandler <VlcMediaPlayerPlayingEventArgs> playingCb = null; playingCb = (s, e2) => { ctl.MediaPlayer.Video.Tracks.Current = ctl.MediaPlayer.Video.Tracks.All.ElementAt(trackIdx); if (ctl.MediaPlayer.Audio.Tracks.Count > 0) { ctl.MediaPlayer.Audio.Tracks.Current = ctl.MediaPlayer.Audio.Tracks.All.First(); //disable } ctl.MediaPlayer.Playing -= playingCb; }; ctl.MediaPlayer.Playing += playingCb; return(ctl); }
private void OpenFile(string path) { _lastFile = path; _medialUrl = $"file:///{path.Replace('\\', '/')}"; VM.ClearVideoSources(); var mainSrc = new VlcVideoSourceProvider(Dispatcher); mainSrc.CreatePlayer(_vlcLibDir); mainSrc.MediaPlayer.SetMedia(_medialUrl); mainSrc.MediaPlayer.Playing += MediaPlayer_Playing; mainSrc.MediaPlayer.PositionChanged += MediaPlayer_PositionChanged; mainSrc.MediaPlayer.TimeChanged += MediaPlayer_TimeChanged; mainSrc.MediaPlayer.EndReached += MediaPlayer_EndReached; mainSrc.MediaPlayer.Play(); VM.AddVideoSource(mainSrc); VM.MainSource = mainSrc; }
public MainWindow() { try { log.Info("MainWindow - ctor "); InitializeComponent(); var currentAssembly = Assembly.GetEntryAssembly(); 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.sourceProvider = new VlcVideoSourceProvider(this.Dispatcher); this.sourceProvider2 = new VlcVideoSourceProvider(this.Dispatcher); this.sourceProvider.CreatePlayer(libDirectory /* pass your player parameters here */); this.sourceProvider2.CreatePlayer(libDirectory /* pass your player parameters here */); this.Video.SetBinding(System.Windows.Controls.Image.SourceProperty, new Binding(nameof(VlcVideoSourceProvider.VideoSource)) { Source = sourceProvider }); this.Video2.SetBinding(System.Windows.Controls.Image.SourceProperty, new Binding(nameof(VlcVideoSourceProvider.VideoSource)) { Source = sourceProvider }); Start(); } catch (Exception ex) { log.Error("MainWindow - ctor -", ex); } }