Ejemplo n.º 1
0
        public VideoPlayer(VideoPlayerViewModel viewModel)
        {
            ViewModel   = viewModel;
            DataContext = viewModel;

            InitializeComponent();

            _streamWatchdogTimer.Interval = StreamWatchDogInterval;
            _streamWatchdogTimer.Tick    += (sender, args) =>
            {
                var mediaUri = ViewModel.MediaUri;
                if (mediaUri == null || _vlcControl.VlcMediaPlayer.IsPlaying())
                {
                    ViewModel.HasError = false;
                    return;
                }

                ViewModel.HasError = true;
                Console.WriteLine($"mediaPlayer {ViewModel.Index} is not playing stream {mediaUri}, attempting to restart it.");
                Play(mediaUri);
            };
            ViewModel.PropertyChanged += ViewModelOnPropertyChanged;

            _vlcControl           = new VlcControl();
            PlayerContainer.Child = _vlcControl;
            _vlcControl.BeginInit();
            _vlcControl.VlcLibDirectory = LibDirectory;
            _vlcControl.EndInit();

            _vlcControl.VlcMediaPlayer.Log += MediaPlayerOnLog;
        }
Ejemplo n.º 2
0
        private void frmKruBot_Load(object sender, EventArgs e)
        {
            vlc.BeginInit();
            vlc.VlcLibDirectory = Vlc_VlcLibDirectoryNeeded();
            var options = new[]
            {
                "--audio-filter", "normvol", "--norm-max-level", "1.5"
            }; //VLC Options - Command Line specifically. Normalizing Volume here.

            vlc.VlcMediaplayerOptions = options;
            vlc.EndInit();
            vlc.Dock = DockStyle.Fill;
            tabYouTube.Controls.Add(vlc);
            vlc.Audio.Volume = tbMusicVolume.Value;
            //VLC set up.

            var cred = JsonConvert.DeserializeObject <creds>(File.ReadAllText("creds.json"));
            //Loads our Twitch Credentials from the Json file.
            var credentials = new ConnectionCredentials(cred.username, cred.oauth);

            client.Initialize(credentials, "pfckrutonium"); //Channel were connecting to.
            client.OnConnected       += Client_OnConnected;
            client.OnJoinedChannel   += Client_OnJoinedChannel;
            client.OnMessageReceived += Client_OnMessageReceived;
            client.Connect();
            rtbChat.LinkClicked += RtbChat_LinkClicked; //Enable clicking on links in Chat.
        }
Ejemplo n.º 3
0
        private void TemplateDataSet_TemplateDataSetChanged(TemplateDataSetEventArgs e)
        {
            streamUrl = _mTemplate.TemplateDataSet.GetTemplateDataSetItemAsText(KeyTvUrl, string.Empty);
            var templatePath = _mTemplate.Attributes["TemplatePath"];
            var libPath      = Path.Combine(templatePath, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64");
            var libDirectory = new DirectoryInfo(libPath);

            vlcControl.BeginInit();
            vlcControl.VlcLibDirectory = libDirectory;
            vlcControl.EndInit();
        }
Ejemplo n.º 4
0
        public IPCAMPLAYER()
        {
            InitializeComponent();
            videoplayer.Child = control;
            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"));

            control.BeginInit();
            control.VlcLibDirectory = libDirectory;
            control.EndInit();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 播放视频流等
        /// </summary>
        /// <param name="border"></param>
        /// <param name="panelItem"></param>
        public static void SetBorderChildByVLC(Border border, CameraPanelItem panelItem)
        {
            if (border.DataContext is CameraPanelItem oldItem)
            {
                border.DataContext = null;
                border.Child       = null;
            }
            border.DataContext = panelItem;

            if (UseWPFControl)
            {
                Vlc.DotNet.Wpf.VlcControl vlcControl = new Vlc.DotNet.Wpf.VlcControl();
                vlcControl.SourceProvider.CreatePlayer(libDirectory);

                if (panelItem.RtspStrs.Count > 1)
                {
                    VLCGroup vlcGroup = new VLCGroup(1, 15);
                    vlcGroup.PlayOnWPF(vlcControl, panelItem.RtspStrs);
                }
                else
                {
                    vlcControl.SourceProvider.MediaPlayer.Play(new Uri(panelItem.RtspStrs[0]));
                }
                border.Child = vlcControl;
            }
            else
            {
                VlcControl vlcControl = new VlcControl();
                string     ratio      = border.ActualWidth + ":" + border.ActualHeight;
                vlcControl.BeginInit();
                vlcControl.VlcLibDirectory = libDirectory;
                vlcControl.EndInit();
                WindowsFormsHost windowsFormsHost = new WindowsFormsHost
                {
                    Child = vlcControl
                };
                border.Child = windowsFormsHost;
                vlcControl.Video.FullScreen  = true;
                vlcControl.Video.AspectRatio = ratio;

                if (panelItem.RtspStrs.Count > 1)
                {
                    VLCGroup vlcGroup = new VLCGroup(1, 15);
                    vlcGroup.Play(vlcControl, panelItem.RtspStrs);
                }
                else
                {
                    vlcControl.Play(new Uri(panelItem.RtspStrs[0]));
                }
            }
        }
Ejemplo n.º 6
0
        public VLCVideoViewModel(Stylet.IEventAggregator events) : base(events)
        {
            _mediaPlayer = new Vlc.DotNet.Forms.VlcControl();

            // Default installation path of VideoLAN.LibVLC.Windows
            var libDirectory = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));

            _mediaPlayer.BeginInit();
            _mediaPlayer.VlcLibDirectory = libDirectory;
            _mediaPlayer.EndInit();

            _mediaPlayer.EndReached       += _mediaPlayer_EndReached;
            _mediaPlayer.Playing          += _mediaPlayer_Playing;
            _mediaPlayer.PositionChanged  += _mediaPlayer_PositionChanged;
            _mediaPlayer.EncounteredError += _mediaPlayer_EncounteredError;
        }
Ejemplo n.º 7
0
        private void OpenFile_Click()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();


            if (openFileDialog.ShowDialog() == true)
            {
                control.BeginInit();
                FileInfo fileInfo = new FileInfo(openFileDialog.FileName);

                control.SourceProvider.MediaPlayer.Play(fileInfo);
                control.SourceProvider.MediaPlayer.Time         = 110000;
                control.SourceProvider.MediaPlayer.Paused      += MediaPlayer_Paused;
                control.SourceProvider.MediaPlayer.TimeChanged += MediaPlayer_TimeChanged;
                control.EndInit();
            }
        }
Ejemplo n.º 8
0
        private void FindVlcLocation()
        {
            DirectoryInfo dirInfo = Utilities.FindVlcLibDirectory();

            if (dirInfo != null)
            {
                vlcControl = new VlcControl();
                vlcControl.BeginInit();
                vlcControl.Margin          = new Padding(0, 0, 0, 3);
                vlcControl.Dock            = DockStyle.Fill;
                vlcControl.VlcLibDirectory = dirInfo;
                vlcControl.EndInit();
                vlcPlayerTableLayoutPanel.Controls.Add(vlcControl, 0, 0);
                vlcPlayerTableLayoutPanel.SetColumnSpan(vlcControl, 3);
                vlcPlayerTableLayoutPanel.Controls.Add(vlcControl);
            }
        }
        public VideoPlayer(VideoPlayerViewModel viewModel)
        {
            ViewModel   = viewModel;
            DataContext = viewModel;

            InitializeComponent();

            ViewModel.PropertyChanged += ViewModelOnPropertyChanged;

            _vlcControl           = new VlcControl();
            PlayerContainer.Child = _vlcControl;
            _vlcControl.BeginInit();
            _vlcControl.VlcLibDirectory = LibDirectory;
            _vlcControl.EndInit();

            _vlcControl.VlcMediaPlayer.Log += MediaPlayerOnLog;
        }
Ejemplo n.º 10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.trackBar1.ValueChanged += new EventHandler(this.trackBar1_ValueChanged);

            control = new VlcControl();
            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"));

            control.BeginInit();
            control.VlcLibDirectory = libDirectory;
            control.Dock            = DockStyle.Fill;
            control.EndInit();
            panel1.Controls.Add(control);
            listBox1.MouseDoubleClick += new MouseEventHandler(listBox1_MouseDoubleClick);
            button8.Click             += new EventHandler(this.button8_Click);
        }
Ejemplo n.º 11
0
        private void InitializeVlcPlayer()
        {
            VlcPlayer      = new VlcControl();
            VlcPlayer.Dock = DockStyle.Fill;

            // TODO 最好可以配置
            VlcPlayer.BeginInit();

            DirectoryInfo vlcLibDirectory = null;

            foreach (var item in new string[] { "C", "D", "E" })
            {
                vlcLibDirectory = new DirectoryInfo(item + @":\Program Files (x86)\VideoLAN\VLC");
                if (vlcLibDirectory.Exists)
                {
                    break;
                }
            }

            if (vlcLibDirectory != null && !vlcLibDirectory.Exists)
            {
                foreach (var item in new string[] { "C", "D", "E" })
                {
                    vlcLibDirectory = new DirectoryInfo(item + @":\Program Files\VideoLAN\VLC");
                    if (vlcLibDirectory.Exists)
                    {
                        break;
                    }
                }
            }

            VlcPlayer.VlcLibDirectory = vlcLibDirectory;

            VlcPlayer.EndInit();

            if (vlcLibDirectory.Exists)
            {
                this.Controls.Add(VlcPlayer);
            }
            else
            {
                this.Visible = false;
            }
        }
Ejemplo n.º 12
0
        private void initConfig()
        {
            vlcControl1 = new VlcControl();


            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"));

            vlcControl1.BeginInit();
            vlcControl1.VlcLibDirectory = libDirectory;
            vlcControl1.Dock            = DockStyle.Fill;
            vlcControl1.EndInit();
            //control.Dock = DockStyle.Fill;
            this.Controls.Add(vlcControl1);
            //vlcControl1.Click += VlcControl1_Click;
            //this.FormClosing += FrmToGo1_FormClosing;
        }
Ejemplo n.º 13
0
        public MainWindow()
        {
            InitializeComponent();
            var control = new VlcControl();

            this.WindowsFormsHost.Child = control;


            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"));

            control.BeginInit();
            control.VlcLibDirectory = libDirectory;
            control.EndInit();

            control.Play(new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"));
        }
Ejemplo n.º 14
0
        public static VlcControl CreateVlcControl(Form hostForm)
        {
            var result = new VlcControl()
            {
                Location  = new Point(0, 0),
                Size      = hostForm.Size,
                BackColor = Color.FromArgb(110, 110, 110),
                Dock      = DockStyle.Fill,
            };

            result.BeginInit();

            LoadVlcConfig();
            if (null != _vlcOptions)
            {
                result.VlcMediaplayerOptions = _vlcOptions;
            }

            result.VlcLibDirectory = new DirectoryInfo(@"libvlc\win-x86");
            result.EndInit();

            hostForm.Controls.Add(result);


            result.VlcMediaPlayer.EndReached += (sender, args) =>
            {
                hostForm.BeginInvoke(new Action(() =>
                {
                    //ReCreateVlcControl( result, hostForm );
                    //RecycleVlcControl( result, hostForm );
                    ReplayMedia(result, hostForm);
                }));
            };



            result.SetMedia(new FileInfo(source));

            result.Play();

            return(result);
        }
Ejemplo n.º 15
0
        public VideoViewPresenter(MainView mainView, FileInfo file)
        {
            _mainView              = mainView;
            _videoView             = new VideoView();
            _vlcControl1           = new VlcControl();
            _videoView.FormClosed += OnFormClose;
            //Initialize video control
            _vlcControl1.BeginInit();
            _vlcControl1.VlcLibDirectory       = new DirectoryInfo(Base._exeFolder + @"\libvlc\win-x86");
            _vlcControl1.VlcMediaplayerOptions = new[] { "-vv" };
            _vlcControl1.EndInit(); //End of init



            _vlcControl1.Click           += vlcControl1_Click;
            _videoView.trackBar1.Scroll  += trackBar1_Scroll;
            _vlcControl1.Playing         += new EventHandler <VlcMediaPlayerPlayingEventArgs>(SetProgressMax);
            _vlcControl1.PositionChanged += new System.EventHandler <Vlc.DotNet.Core.VlcMediaPlayerPositionChangedEventArgs>(vlcControl1_PositionChanged);
            _file = file;
        }
Ejemplo n.º 16
0
        private void InitializeVLCControl()
        {
            var vlcControl = new VlcControl
            {
                BackColor             = Color.Black,
                Dock                  = DockStyle.Fill,
                Location              = new Point(0, 0),
                Size                  = new Size(944, 501),
                Spu                   = -1,
                TabIndex              = 0,
                VlcLibDirectory       = null,
                VlcMediaplayerOptions = null
            };

            vlcControl.BeginInit();
            SuspendLayout();

            vlcControl.VlcLibDirectoryNeeded += OnVLCLibDirectoryNeeded;
            vlcControl.EncounteredError      += (sender, args) =>
            {
                Invoke((MethodInvoker) delegate
                {
                    DisplayInfo("Error");
                });
            };

            vlcControl.Stopped += (sender, args) =>
            {
                Invoke((MethodInvoker) delegate
                {
                    DisplayInfo("Stopped");
                });

                vlcControl.Play();
            };

            vlcControl.Paused += (sender, args) =>
            {
                Invoke((MethodInvoker) delegate
                {
                    DisplayInfo("Paused");
                });
            };

            vlcControl.Buffering += (sender, args) =>
            {
            };

            vlcControl.Playing += (sender, args) =>
            {
                Invoke((MethodInvoker) delegate
                {
                    DisplayInfo(_currentChannel.ToString());
                });
            };

            vlcPanel.Controls.Add(vlcControl);

            vlcControl.EndInit();

            ResumeLayout(false);

            _vlcControl = vlcControl;
        }
Ejemplo n.º 17
0
        void OpenNewScreen(int screen)
        {
            foreach (UrlPanel urlPanel in Panel_List)
            {
                urlPanel.Url = urlPanel.panel.Controls.OfType<TextBox>().ToList()[0].Text;
                urlPanel.Label = urlPanel.panel.Controls.OfType<TextBox>().ToList()[1].Text;
            }

            form3 = new Form();
            form3.Controls.Clear();
            Screen screenToUse = Screen.AllScreens[screen];

            form3.FormBorderStyle = FormBorderStyle.None;
            form3.Icon = Properties.Resources.DispatchViewer;
            form3.WindowState = FormWindowState.Maximized;
            form3.BackColor = Color.Black;
            form3.FormClosed += new FormClosedEventHandler(Form_Closing);

            form3.StartPosition = FormStartPosition.Manual;
            form3.Location = screenToUse.Bounds.Location;

            ContextMenuStrip menu = new ContextMenuStrip();
            menu.Items.Add("Exit");
            menu.ItemClicked += Menu_ItemClicked;
            form3.ContextMenuStrip = menu;

            int count = 0;
            int ScreenH = screenToUse.Bounds.Height; int ScreenW = screenToUse.Bounds.Width;
            int total = Panel_List.Count;

            int rows = 0;
            int cols = 0;

            if (AttemptedCols != 0 & AttemptedRows != 0)
            {
                cols = AttemptedCols;
                rows = AttemptedRows;
            }
            else
            {
                if (Panel_List.Count == 1)
                {
                    rows = 1;
                    cols = 1;
                }
                else
                {
                    if (ScreenH < ScreenW)
                    {
                        rows = 2;
                        cols = Convert.ToInt32(Math.Ceiling((decimal)total / 2));
                    }
                    else
                    {
                        cols = 2;
                        rows = Convert.ToInt32(Math.Ceiling((decimal)total / 2));
                    }
                }
            }

            try
            {
                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < cols; j++)
                    {
                        UrlPanel urlPanel = Panel_List[count];

                        VlcControl vlcControl = new VlcControl();
                        vlcControl.BeginInit();
                        vlcControl.VlcLibDirectory = vlcLibDirectory;
                        vlcControl.VlcMediaplayerOptions = new[] { "-vvv" };
                        vlcControl.EndInit();
                        vlcControl.SetMedia(urlPanel.Url);

                        vlcControl.Play();
                        vlcControl.Enabled = true;

                        vlcControl.Dock = DockStyle.None;
                        vlcControl.Size = new Size(ScreenW / cols, (ScreenH / rows) - 30);
                        vlcControl.Location = new Point((ScreenW / cols) * j, (ScreenH / rows) * i + 30);

                        #region Label
                        Label AddressLabel = new Label
                        {
                            Text = (urlPanel.Label != String.Empty) ? urlPanel.Label : urlPanel.Url,
                            Height = 30,
                            Width = (ScreenW / cols) / 3,

                            Font = new Font(Font.FontFamily, 16),
                            ForeColor = Color.White,
                            Cursor = Cursors.Hand,
                            AutoEllipsis = true,

                            Tag = vlcControl,
                            Location = new Point((ScreenW / cols) * j, (ScreenH / rows) * i)
                        };
                        AddressLabel.Click += new EventHandler(Label_Clicked);

                        #endregion

                        Button button1 = new Button
                        {
                            Text = "Rec.",
                            BackColor = Color.White,
                            Height = 30,
                            Width = 65,
                            Font = new Font(Font.FontFamily, 10),
                            Location = new Point(AddressLabel.Right + 15, AddressLabel.Location.Y),
                            Tag = vlcControl
                        };
                        button1.Click += button1_Click;

                        form3.Controls.Add(button1);
                        form3.Controls.Add(AddressLabel);
                        form3.Controls.Add(vlcControl);
                        VlcControlList.Add(vlcControl);

                        count++;
                    }
                }
            }
            catch (Exception)
            {
            }

            form3.Show();
            formOpen = true;
        }