示例#1
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.
        }
示例#2
0
        public SortForm(SortProject project, MainForm mainForm, bool randomSort)
        {
            InitializeComponent();
            _randomSort = randomSort;
            _mainForm   = mainForm;
            _project    = project;

            // vlc control used for webms
            _vlcControl = new VlcControl();
            _vlcControl.VlcMediaplayerOptions  = new string[] { "--loop" };
            _vlcControl.VlcLibDirectoryNeeded += VlcLibDirectoryNeeded;
            _vlcControl.EndReached            += EndReached;
            _vlcControl.Dock            = DockStyle.Fill;
            _vlcControl.BackColor       = SystemColors.Control;
            _vlcControl.VlcLibDirectory = new DirectoryInfo(".");
            _vlcControl.EndInit();
            _vlcControl.Visible = false;

            // picture box used for everything else - the vlc control can show images, but it's a lot slower than the picture box
            // we disable both and choose which one to display based on the filetype of the current image
            _pictureBox          = new PictureBox();
            _pictureBox.Dock     = DockStyle.Fill;
            _pictureBox.Visible  = false;
            _pictureBox.SizeMode = PictureBoxSizeMode.Zoom;

            splitter.Panel1.Controls.Add(_vlcControl);
            splitter.Panel1.Controls.Add(_pictureBox);

            // load the first image
            LoadImage(FindNextImage());
        }
示例#3
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;
        }
示例#4
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();
        }
示例#5
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();
        }
示例#6
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]));
                }
            }
        }
示例#7
0
 public static VlcControl CraftClvControl()
 {
     try
     {
         VlcControl vlc = new VlcControl();
         vlc.VlcLibDirectory = new DirectoryInfo(InstallDir);
         vlc.EndInit();
         return(vlc);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
示例#8
0
        /// <summary>
        /// The PlayerForm class constructor.
        /// </summary>
        public FormPlayer()
        {
            InitializeComponent();

            DBLangEngine.DBName = "lang.sqlite"; // Do the VPKSoft.LangLib == translation

            if (VPKSoft.LangLib.Utils.ShouldLocalize() != null)
            {
                DBLangEngine.InitalizeLanguage("vamp.Messages", VPKSoft.LangLib.Utils.ShouldLocalize(), false);
                return; // After localization don't do anything more.
            }

            DBLangEngine.InitalizeLanguage("vamp.Messages");

            vlcControl = new VlcControl();    // Create the actual VLC Player control..
            this.Controls.Add(vlcControl);    // Add the control to the form..
            vlcControl.Dock = DockStyle.Fill; // ..dock it to fill the form

            if (Environment.Is64BitProcess)   // Depending on the processor architecture (a 64 or 32 bits of this process) a library path needs to be chosen
            {
                vlcControl.VlcLibDirectory = new DirectoryInfo(Path.GetDirectoryName(Application.ExecutablePath) + @"\libvlc_x64\");
            }
            else
            {
                vlcControl.VlcLibDirectory = new DirectoryInfo(Path.GetDirectoryName(Application.ExecutablePath) + @"\libvlc_x86\");
            }

            if (!vlcControl.VlcLibDirectory.Exists) // Check, if the VLC library path exists and complain, if it doesn't..
            {
                MessageBox.Show(DBLangEngine.GetMessage("msgVLCLibMissing", "The VLC Library is missing. The playback will be aborted.|As in the VLC library (dll's and stuff) is missing, so no video playback will occur!"), DBLangEngine.GetMessage("msgError", "Error|A message describing that some kind of error occurred."), MessageBoxButtons.OK, MessageBoxIcon.Error);
                using (vlcControl) // Dispose the VLC control and return.. there is nothing more to do here..
                {
                    return;
                }
            }

            vlcControl.EncounteredError += VlcControl_EncounteredError;

            vlcControl.EndInit();                     // This must be called, otherwise exceptions will get thrown..

            SetButtonImages();                        // set the button images..

            lbToolTip.Text = string.Empty;            // Hide the useless design time tool-tip..

            vlcControl.Stopped += VlcControl_Stopped; // The playback stopped.. this indicates that the media was watched to the end, so the form will close.

            SetMedia();                               // Set the playback source with options for the VLCControl..
        }
示例#9
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;
        }
示例#10
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;
        }
示例#12
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();
            }
        }
示例#13
0
文件: Form1.cs 项目: VijayRed01/TS1_C
        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);
        }
示例#14
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;
            }
        }
示例#15
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;
        }
        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"));
        }
示例#17
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);
        }
示例#18
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;
        }
示例#19
0
        /// <summary>
        /// Add one player to the panel asynchronously.
        /// </summary>
        /// <returns></returns>
        private async Task AddPlayerAsync()
        {
            await Task.Run(async() =>
            {
                var player = new VlcControl
                {
                    VlcLibDirectory = new DirectoryInfo(this.vlcLibraryPath),
                    Size            = new Size(200, 200)
                };

                var uiUpdatedTask = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously);
                panel.BeginInvoke((MethodInvoker) delegate
                {
                    panel.Controls.Add(player);
                    player.EndInit();
                    uiUpdatedTask.SetResult(true);
                });

                await uiUpdatedTask.Task.ConfigureAwait(false);

                lock (listOfControls)
                {
                    // Add to a list
                    listOfControls.Add(player);
                }

                HookEvents(player);

                // If any of the following 2 elements is true, then the vlc player itself will capture input from the user.
                // and then, the mouse click event won't fire.
                player.Video.IsMouseInputEnabled = false;
                player.Video.IsKeyInputEnabled   = false;
                player.Audio.IsMute = true;

                // Tell the player to play
                player.SetMedia(textBox1.Text, StreamParams);
                player.Play();
            });
        }
示例#20
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;
        }
示例#21
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;
        }