void playAndRetry(string videoId, int streamIndex = -1)
 {
     if (play(videoId, streamIndex))
     {
         _fluentAverageCalculator = new FluentAverageCalculator();
     }
     else
     {
         if (videoId == VideoId)
         {
             TimerCallback callback = x =>
             {
                 WindowUtil.BeginInvoke(() => playAndRetry(videoId, streamIndex));
             };
             if (_tryTimes++ >= 10)
             {
                 string msg = "============已尝试很多次,仍无法播放视频:{0} ========";
                 Console.WriteLine(msg, videoId);
                 Common.Log.Logger.Default.Error(msg, videoId);
             }
             else
             {
                 _timer = new Timer(callback, null, 500, Timeout.Infinite);
             }
         }
     }
 }
 void updateImageSource(ImageSource imgSrc)
 {
     WindowUtil.BeginInvoke(() =>
     {
         this.ImageSrc = imgSrc;
     });
 }
Esempio n. 3
0
 private void MoniterMouseLeave()
 {
     do
     {
         Thread.Sleep(1000);
         bool flag = GetIsMouseLeaved();
         if (flag)
         {
             SetMonitorFlag(true);
             Thread.Sleep(1000);
             flag = GetIsMouseLeaved() && GetMonitorFlag();
             if (flag)
             {
                 try
                 {
                     WindowUtil.BeginInvoke(() =>
                     {
                         if (this.ControlState != Visibility.Hidden && WindowState == WindowState.Maximized)
                         {
                             this.ControlState = Visibility.Collapsed;
                         }
                     });
                 }
                 catch (NullReferenceException)
                 {
                     //在应用程序(域)退出时,有可能引发此异常。
                 }
                 break;
             }
         }
     }while (true);
 }
Esempio n. 4
0
 private void diProxy_VideoDataInfoReceived(object sender, VideoDataInfoEventArgs e)
 {
     WindowUtil.BeginInvoke(() =>
     {
         updateVideoDataInfo(e.VideoId, e.StreamId, e.TimePeriods);
     });
 }
Esempio n. 5
0
 private void onLocalSourceInfoReceived(LocalVideosInfoPacket obj)
 {
     WindowUtil.BeginInvoke(() =>
     {
         UpdateTimePeriod(obj.TimePeriod.BeginTime, obj.TimePeriod.EndTime);
     });
 }
Esempio n. 6
0
        async void updatePermission()
        {
            await Task.Delay(TimeSpan.FromSeconds(0.5));// TODO:获取用户权限

            WindowUtil.BeginInvoke(_publisher.NotifyPermissionUpdated);
            CommandManager.InvalidateRequerySuggested();
        }
Esempio n. 7
0
        private void updateImage(ThumbnailInfo info)
        {
            updateOnlineStatus();
            System.Drawing.Image bmp = info.Thumbnail;

            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);// 格式自处理,这里用 bitmap
                try
                {
                    WindowUtil.BeginInvoke(() =>
                    {
                        var bi = new System.Windows.Media.Imaging.BitmapImage();
                        bi.BeginInit();
                        bi.StreamSource = new MemoryStream(ms.ToArray()); // 不要直接使用 ms
                        bi.EndInit();
                        Thumbnail = bi;
                    });
                }
                catch
                {
                    Dispose();
                }
            }
        }
 private void onVideoFrameImage(ImageSource obj)
 {
     WindowUtil.BeginInvoke(() =>
     {
         this.ImageSrc = obj;
         Console.WriteLine(StreamManager?.VideoName + ": Image Source Updated!");
     });
 }
 void updateStretch()
 {
     WindowUtil.BeginInvoke(() =>
     {
         Stretch stretch  = this.StretchMode;
         this.StretchMode = Stretch.None;
         this.StretchMode = stretch;
     });
 }
Esempio n. 10
0
 private void onPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     switch (e.PropertyName)
     {
     case nameof(ID):
         ThumbnailsPack.Instance.RemoveUpdateHandler(_oldId, updateImage);
         WindowUtil.BeginInvoke(() => { Thumbnail = new System.Windows.Media.Imaging.BitmapImage(); });
         ThumbnailsPack.Instance.AddUpdateHandler(ID, updateImage);
         _oldId = ID;
         break;
     }
 }
Esempio n. 11
0
 void onTrackRect(TrackRect rect)
 {
     try
     {
         _rect = rect;
         WindowUtil.BeginInvoke(() =>
         {
             updateTrackRect();
         });
     }
     catch
     { }
 }
Esempio n. 12
0
 void playAndRetry(string videoId, int streamIndex = -1)
 {
     if (!play(videoId, streamIndex))
     {
         if (!_disposed)
         {
             TimerCallback callback = x =>
             {
                 WindowUtil.BeginInvoke(() => playAndRetry(videoId, streamIndex));
             };
             _timer = new Timer(callback, null, 500, Timeout.Infinite);
         }
     }
 }
Esempio n. 13
0
        private void DisplayModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(DisplayModel.StreamInfoArray):
                updateStreamTypes();
                break;

            case nameof(DisplayModel.StreamName):
                WindowUtil.BeginInvoke(() => { SelectedStreamType = DisplayModel.StreamName == null ? DefaultStreamType : DisplayModel.StreamName; });
                break;

            case nameof(DisplayModel.VideoName):
                if (PTZControl.IsShowControl)
                {
                    PTZControl.UpdatePTZStatus();
                    TrackSource.LoadTrackSwap(VideoId);
                    SwitchModel.UpdateSwitchInfo();
                }
                break;
            }
        }
Esempio n. 14
0
        async void login()
        {
            await DialogDispatcher.UIInitCompletion.Task;

            WindowUtil.BeginInvoke(doLogin);
        }