예제 #1
0
 public static bool CanPause(this VlcControl control)
 {
     return(control.SourceProvider.MediaPlayer.IsPlaying());
 }
예제 #2
0
 public static void Pause(this VlcControl control)
 {
     control.SourceProvider.MediaPlayer.Pause();
 }
예제 #3
0
 public static float GetPosition(this VlcControl control)
 {
     return(control.SourceProvider.MediaPlayer.Position);
 }
예제 #4
0
 public static bool IsMuted(this VlcControl control, bool value)
 {
     return(control.SourceProvider.MediaPlayer.Audio.IsMute = value);
 }
예제 #5
0
 public static void Source(this VlcControl control, Stream stream)
 {
     control.SourceProvider.MediaPlayer.Play(stream);
 }
예제 #6
0
 public static bool IsStop(this VlcControl control)
 {
     return(!(control.SourceProvider.MediaPlayer.IsPlaying()));
 }
예제 #7
0
 public static void Stop(this VlcControl control)
 {
     control.SourceProvider.MediaPlayer.Stop();
 }
예제 #8
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;
        }
예제 #9
0
 private void PlayerOnLengthChanged(VlcControl sender, VlcEventArgs <long> vlcEventArgs)
 {
     Duration = _player.Duration;
 }
예제 #10
0
 private void PlayerOnPositionChanged(VlcControl sender, VlcEventArgs <float> vlcEventArgs)
 {
     _media.Source = _player.VideoSource;
     Position      = _player.Time;
 }
예제 #11
0
 void VlcInitializedHandler(object sender, EventArgs e)
 {
     MyVlcControl = new VlcControl();
     InitializeComponent();
 }
예제 #12
0
 private void VlcControlOnTimeChanged(VlcControl sender, VlcEventArgs<TimeSpan> e)
 {
     if(myVlcControl.Media == null)
         return;
     var duration = myVlcControl.Media.Duration;
     textBlock.Text = string.Format(
         "{0:00}:{1:00}:{2:00} / {3:00}:{4:00}:{5:00}",
         e.Data.Hours,
         e.Data.Minutes,
         e.Data.Seconds,
         duration.Hours,
         duration.Minutes,
         duration.Seconds);
 }
예제 #13
0
        /// <summary>
        /// Called by the <see cref="VlcControl"/> when the media position changed during playback.
        /// </summary>
        /// <param name="sender">Event sennding control. </param>
        /// <param name="e">VLC event arguments. </param>
        private void VlcControlOnPositionChanged(VlcControl sender, VlcEventArgs<float> e)
        {
            if (myPositionChanging)
            {
                // User is currently changing the position using the slider, so do not update. 
                return;
            }

            sliderPosition.Value = e.Data;
        }
예제 #14
0
 private void OnStopButtonClick(object sender, RoutedEventArgs e)
 {
     this.control?.Dispose();
     this.control = null;
 }
예제 #15
0
 public static void Source(this VlcControl control, string uri)
 {
     control.SourceProvider.MediaPlayer.Play(new Uri(uri));
 }
예제 #16
0
파일: VlcPlayer.cs 프로젝트: ch4/vlcdotnet
 /// <summary>
 /// Event handler for the <see cref="VlcControl.PositionChanged"/> event. 
 /// Updates the label containing the playback position. 
 /// </summary>
 /// <param name="sender">Event sending <see cref="VlcControl"/>. </param>
 /// <param name="e">Event arguments, containing the current position. </param>
 private void VlcControlOnPositionChanged(VlcControl sender, Core.VlcEventArgs<float> e)
 {
     labelPlaybackPosition.Text = (e.Data * 100).ToString("000") + " %";
 }
예제 #17
0
        public override void OnApplyTemplate()
        {
            this.UnRegisterEvent();

            base.OnApplyTemplate();

            this.PART_VlcControl = this.GetTemplateChild("PART_VlcControl") as VlcControl;
            if (this.PART_VlcControl != null)
            {
                var vlcLibDirectory = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "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.
                };

                Task.Run(() =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        this.IsVlcControlLoading = true;
                    });
                    this.PART_VlcControl.SourceProvider.CreatePlayer(vlcLibDirectory, options);
                }).ContinueWith((t) =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        this.IsVlcControlLoading = false;
                        this.RegisterEvent();
                        if (this.PART_Volume_Slider != null)
                        {
                            this.PART_Volume_Slider.Maximum = InitVolume;
                            this.PART_Volume_Slider.Minimum = 0;
                            this.PART_Volume_Slider.Value   = this.Volume;
                        }
                    });
                });
            }

            this.PART_Btn_Play       = this.GetTemplateChild("PART_Btn_Play") as Button;
            this.PART_Btn_Pause      = this.GetTemplateChild("PART_Btn_Pause") as Button;
            this.PART_Btn_Stop       = this.GetTemplateChild("PART_Btn_Stop") as Button;
            this.PART_Btn_Next       = this.GetTemplateChild("PART_Btn_Next") as Button;
            this.PART_Btn_Previous   = this.GetTemplateChild("PART_Btn_Previous") as Button;
            this.PART_Time_Current   = this.GetTemplateChild("PART_Time_Current") as Run;
            this.PART_Time_Total     = this.GetTemplateChild("PART_Time_Total") as Run;
            this.PART_Video_Time     = this.GetTemplateChild("PART_Video_Time") as TextBlock;
            this.PART_Bottom_Tool    = this.GetTemplateChild("PART_Bottom_Tool") as Border;
            this.PART_Slider         = this.GetTemplateChild("PART_Slider") as AduFlatSilder;
            this.PART_Btn_Slower     = this.GetTemplateChild("PART_Btn_Slower") as Button;
            this.PART_Btn_Faster     = this.GetTemplateChild("PART_Btn_Faster") as Button;
            this.PART_MouseOver_Area = this.GetTemplateChild("PART_MouseOver_Area") as Border;
            this.PART_Volume_Slider  = this.GetTemplateChild("PART_Volume_Slider") as Slider;
            this.PART_Loading        = this.GetTemplateChild("PART_Loading") as AduLoading;
            //播放地址
            this.PART_PlayInfo          = this.GetTemplateChild("PART_PlayInfo") as Border;
            this.PART_Txt_VideoSource   = this.GetTemplateChild("PART_Txt_VideoSource") as MetroTextBox;
            this.PART_Btn_PlayLocalFile = this.GetTemplateChild("PART_Btn_PlayLocalFile") as AduFlatButton;
            this.PART_Btn_PlayUri       = this.GetTemplateChild("PART_Btn_PlayUri") as AduFlatButton;
            this.PART_Btn_Screenshot    = this.GetTemplateChild("PART_Btn_Screenshot") as Button;
            this.PART_Btn_OpenFile      = this.GetTemplateChild("PART_Btn_OpenFile") as Button;
            this.VideoStoped();
        }