Beispiel #1
0
 private void FrmToGo1_FormClosing(object sender, FormClosingEventArgs e)
 {
     //throw new NotImplementedException();
     if (vlcControl1.IsPlaying)
     {
         vlcControl1.Stop();
         vlcControl1.Dispose();
     }
     vlcControl1.Dispose();
 }
Beispiel #2
0
 private void palyfileBtn_Click(object sender, RoutedEventArgs e)
 {
     vlcControl?.Dispose();
     vlcControl = new VlcControl();
     ControlContainer.Content = vlcControl;
     vlcControl.SourceProvider.CreatePlayer(vlcLibDirectory);
     vlcControl.SourceProvider.MediaPlayer.Play(new Uri("rtmp://58.200.131.2:1935/livetv/hunantv"));
     //FileInfo fileInfo = new FileInfo(@"E:\2.avi");
     //vlcControl.SourceProvider.MediaPlayer.Play(fileInfo);
     Videostatusclock();
 }
 private void clearMusic()
 {
     //1.移除原有背景音乐
     if (musicMediaElement != null)
     {
         musicPause_ByMessage();
         vlcControl?.Dispose();
         mainGrid.Children.Remove(musicMediaElement);
     }
     //2.移除音乐按钮
     if (musicButton != null)
     {
         musicButton.Background = null;
         musicStoryboard.Stop(musicButton);
         mainGrid.Children.Remove(musicButton);
     }
 }
Beispiel #4
0
        protected override void OnClosing(CancelEventArgs eArgs)
        {
            _discoverSvc.Dispose();
            _schedulerSvc.Dispose();
            _vlcControl.Dispose();
            _hub.Dispose();

            base.OnClosing(eArgs);
        }
        private void UserControl_UnLoaded(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("CVideoBackground:UserControl_UnLoaded");
            vlcControl.SourceProvider.MediaPlayer.EndReached -= Video_Element_MediaEnded;
            this.Unloaded -= UserControl_UnLoaded;
            fileInfo       = null;

            Video_Pause( );
            vlcControl.Background = null;
            vlcControl?.Dispose();
            vlcControl            = null;
            Video_Element.Content = null;
            Video_Element         = null;

            Video_Element_Grid.Children.Clear();
            this.Resources.Clear();
            GC.Collect();
        }
Beispiel #6
0
        private void UserControl_UnLoaded(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("CVideo:UserControl_UnLoaded");
            if (isFullScreen)
            {
                mqServer.SendMsg(new VideoControlMessage(currDControl.id, "fullScreenExit"));
            }
            if (isPlaying)
            {
                Video_Pause();
            }
            else
            {
                Video_Pause_ByMessage();
            }
            mqServer.sendMsgEvent    -= Client_ReceiveMsgEvent;
            timelineSliderTimer.Tick -= new EventHandler(TimelineSliderTimer_Tick);
            timelineSliderTimer.Stop();
            hideVideoConsoleTimer.Tick -= new EventHandler(HideVideoConsoleTimer_Tick);
            hideVideoConsoleTimer.Stop();
            vlcControl.SourceProvider.MediaPlayer.EndReached -= Video_Element_MediaEnded;

            Video_Element_Grid.PreviewMouseLeftButtonDown -= Video_Element_Grid_MouseLeftButtonDown;
            Video_Element_Grid.PreviewMouseMove           -= Video_Element_Grid_MouseMove;
            Video_Element_Grid.PreviewMouseLeftButtonUp   -= TimelineSlider_MouseLeftButtonUp;
            Video_Console.PreviewMouseLeftButtonUp        -= Video_Console_MouseUp;

            TimelineSlider.PreviewMouseLeftButtonDown -= TimelineSlider_MouseDown;
            TimelineSlider.PreviewMouseLeftButtonUp   -= TimelineSlider_MouseUp;
            TimelineSlider.PreviewTouchDown           -= TimelineSlider_TouchDown;
            TimelineSlider.PreviewTouchUp             -= TimelineSlider_TouchUp;


            Loaded                  -= UserControl_Loaded;
            Unloaded                -= UserControl_UnLoaded;
            Play_Button.Click       -= Play_Button_Click;
            Fullscreen_Button.Click -= Fullscreen_Button_Click;


            vlcControl.Background = null;
            vlcControl?.Dispose();
            Video_Element.Content = null;

            //logo  关闭按钮  播放按钮  全屏按钮 时间线
            Video_Logo.Source            = null;
            closebtn.Background          = null;
            Play_Button.Background       = null;
            Fullscreen_Button.Background = null;

            Video_Title = null;
            playedTime  = null;
            totalTime   = null;
            Main_Grid.Children.Clear();
            this.Resources.Clear();
            GC.Collect();
        }
        private void this_Unloaded(object sender, RoutedEventArgs e)
        {
            if (isPlaying)
            {
                Video_Pause();
            }
            else
            {
                Video_Pause_ByMessage();
            }
            mqServer.sendMsgEvent -= Client_ReceiveMsgEvent;
            dispatcherTimer.Tick  -= new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Stop();
            vlcControl.SourceProvider.MediaPlayer.EndReached -= Video_Element_MediaEnded;
            Unloaded -= this_Unloaded;

            image.Source = null;
            vlcControl?.Dispose();
            Video_Element.Content = null;

            mainGrid.Children.Clear();
            this.Resources.Clear();
            GC.Collect();
        }
Beispiel #8
0
 public override void Dispose()
 {
     if (!bufferingDone)
     {
         GUIWaitCursor.Hide();                 // hide the wait cursor
     }
     if (osd != null)
     {
         osd.Dispose();
     }
     if (media != null)
     {
         media.Dispose();
     }
     if (vlcCtrl != null)
     {
         vlcCtrl.Dispose();
     }
 }
        private void MediaPlayer_TimeChanged(object sender, VlcMediaPlayerTimeChangedEventArgs e)
        {
            vlcControl.SourceProvider.MediaPlayer.TimeChanged -= MediaPlayer_TimeChanged;

            ThreadPool.QueueUserWorkItem(_ =>
            {
                long length  = vlcControl.SourceProvider.MediaPlayer.Length;
                int duration = Convert.ToInt32(length / 1000.0);


                StorageFile storageFile = storageFileBll.insert(this.sourceFilePath, destFilePath, 1, duration);

                //直接变更控件背景
                App.Current.Dispatcher.Invoke((Action)(() =>
                {
                    backgroundMusicUrl.Text = destFilePath;
                    backgroundMusicUrl.Tag = storageFile;
                }));

                vlcControl?.Dispose();
            });
        }
Beispiel #10
0
        private void MediaPlayer_TimeChanged(object sender, VlcMediaPlayerTimeChangedEventArgs e)
        {
            vlcControl.SourceProvider.MediaPlayer.TimeChanged -= MediaPlayer_TimeChanged;
            string   shotJpg  = FileUtil.replaceExt(destFilePath, "jpg");
            FileInfo shotFile = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + shotJpg);

            ThreadPool.QueueUserWorkItem(_ =>
            {
                Console.WriteLine("视频截图----------");
                vlcControl.SourceProvider.MediaPlayer.TakeSnapshot(shotFile, 0, 0);
                long length  = vlcControl.SourceProvider.MediaPlayer.Length;
                int duration = Convert.ToInt32(length / 1000.0);

                int jpgWidth  = 0;
                int jpgHeight = 0;
                try
                {
                    System.Drawing.Image sourceImage = System.Drawing.Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + shotJpg);
                    jpgWidth  = sourceImage.Width;
                    jpgHeight = sourceImage.Height;
                }
                catch (Exception)
                {
                }
                StorageVideo storageVideo = storageVideoBll.insert(this.sourceFilePath, destFilePath, duration, shotJpg, jpgWidth, jpgHeight, folderId);


                //插入一个视频到列表
                App.Current.Dispatcher.Invoke((Action)(() =>
                {
                    Canvas newVideo = initOneVideo(storageVideo);
                    videoListWrap.Children.Insert(0, newVideo);
                    selectButton(newVideo);
                }));

                vlcControl?.Dispose();
            });
        }
        private void MediaPlayer_TimeChanged(object sender, VlcMediaPlayerTimeChangedEventArgs e)
        {
            vlcControl.SourceProvider.MediaPlayer.TimeChanged -= MediaPlayer_TimeChanged;

            ThreadPool.QueueUserWorkItem(_ =>
            {
                long length  = vlcControl.SourceProvider.MediaPlayer.Length;
                int duration = Convert.ToInt32(length / 1000.0);



                StorageFile storageFile = storageFileBll.insert(this.sourceFilePath, destFilePath, folderId, duration);

                //插入一个音频到列表
                App.Current.Dispatcher.Invoke((Action)(() =>
                {
                    Canvas newImage = initOneFile(storageFile);
                    imageListWrap.Children.Insert(0, newImage);
                    selectButton(newImage);
                }));

                vlcControl?.Dispose();
            });
        }
Beispiel #12
0
        private static void ReCreateVlcControl(VlcControl oldControl, Form hostForm)
        {
            oldControl.Stop();
            oldControl.ResetMedia();
            hostForm.Controls.Remove(oldControl);
            oldControl.Dispose();

            var timer = new TimerX {
                Interval = 1
            };
            ElapsedEventHandler handler = (s, e) =>
            {
                hostForm.BeginInvoke(new Action(() =>
                {
                    CreateVlcControl(hostForm);
                    timer.Enabled = false;
                }));
            };


            timer.Elapsed  += handler;
            timer.AutoReset = false;
            timer.Enabled   = true;
        }
 public void Dispose()
 {
     player.Dispose();
 }
Beispiel #14
0
 private void MainWindow_Closing(object sender, CancelEventArgs e)
 {
     control?.Dispose();
 }
 public static void StopIpCamera(VlcControl vlcControl)
 {
     vlcControl.Stop();
     vlcControl.Dispose();
 }