Ejemplo n.º 1
0
        CameraPanelItem singleOldItem = null;  //全屏播放的视频信息
        /// <summary>
        /// 双击全屏播放视频
        /// </summary>
        /// <param name="index">视频索引</param>
        private void SetSingle(int index)
        {
            if (!isSinglePlay)
            {
                var rows = this.gridVideo.RowDefinitions.Count;
                var cols = this.gridVideo.ColumnDefinitions.Count;
                foreach (UIElement item in this.gridVideo.Children)
                {
                    item.Visibility = Visibility.Hidden;
                }

                singleBorder            = GridHelpers.GetBorderByTag(this.gridVideo.Children, index);
                singleBorder.Visibility = Visibility.Visible;
                singleRowSpan           = (int)singleBorder.GetValue(Grid.RowSpanProperty);
                singleRow      = (int)singleBorder.GetValue(Grid.RowProperty);
                singleColsSpan = (int)singleBorder.GetValue(Grid.ColumnSpanProperty);
                singleCol      = (int)singleBorder.GetValue(Grid.ColumnProperty);

                // 视频源全部换为主码流
                singleOldItem = singleBorder.DataContext as CameraPanelItem;
                CameraPanelItem newItem = singleOldItem.Clone() as CameraPanelItem;
                if (newItem.PlayType == PlayContentType.One && newItem.Camera.StreamType == 1)
                {
                    singleOldItem.GetPlayView().Stop();
                    newItem.Camera.StreamType = 0;
                    changeStream = true;
                }
                if (newItem.PlayType == PlayContentType.Group)
                {
                    for (int i = 0; i < newItem.CameraGroup.Items.Count; i++)
                    {
                        if (newItem.CameraGroup.Items[i].StreamType == 1)
                        {
                            singleOldItem.GetPlayView().Stop();
                            newItem.CameraGroup.Items[i].StreamType = 0;
                            changeStream = true;
                        }
                    }
                }
                if (changeStream)
                {
                    GridHelpers.SetCameraOnBorder(singleBorder, newItem);
                }

                singleBorder.SetValue(Grid.RowProperty, 0);
                singleBorder.SetValue(Grid.ColumnProperty, 0);
                singleBorder.SetValue(Grid.ColumnSpanProperty, cols);
                singleBorder.SetValue(Grid.RowSpanProperty, rows);

                isSinglePlay = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 给对应 Border 放置监控,查看是否已有,有就停止
        /// </summary>
        /// <param name="border"></param>
        /// <param name="panelItem"></param>
        public static void SetCameraOnBorder(Border border, CameraPanelItem panelItem)
        {
            if (border.DataContext is CameraPanelItem oldItem)
            {
                oldItem.GetPlayView().Stop();
                border.DataContext = null;
                border.Child       = null;
            }

            var channel = panelItem.GetPlayView();

            border.DataContext = panelItem;

            var winFormHost = new WindowsFormsHost();
            var playPanle   = new System.Windows.Forms.Panel();

            winFormHost.Child = playPanle;
            border.Background = Brushes.Gray;
            border.Child      = winFormHost;
            playPanle.Controls.Clear();
            channel.OnPlayError += (s, e) =>
            {
                var log = NLog.LogManager.GetCurrentClassLogger();
                log.Error(e.ErrorMessage + e.Code);
            };
            if (channel.Playing)
            {
                channel.Stop();
            }
            channel.Play(winFormHost.Child);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 暂停播放
        /// </summary>
        /// <param name="index"></param>
        private void Pause(int index)
        {
            Border          border = GridHelpers.GetBorderByTag(this.gridVideo.Children, index);
            CameraPanelItem item   = border.DataContext as CameraPanelItem;

            item.GetPlayView().Pause();
        }