示例#1
0
        public void Main()
        {
            try
            {
                int      counter = 0;
                DateTime before  = DateTime.Now;
                while (Xbox.Ping(500))
                {
                    try
                    {
                        if (!mnuPause.Checked && Video.IsActive)
                        {
                            //ParseUserInput();

                            // dont bother updating at full speed if minimized, just poll so we don't lose the stream...
                            if (this.WindowState == FormWindowState.Minimized)
                            {
                                System.Threading.Thread.Sleep(1000);
                            }

                            renderWindow.Image = Video.NextFrame();
                            status.Text        = "Frame: " + Video.FrameNumber; // Xbox.GetUInt32(Xbox.GetUInt32(0xB0033DA0)); (presentation frame number)
                            counter++;
                        }

                        // attempt to recreate videostream before breaking out of the loop
                        // the main reason for it becoming inactive is if its paused for more than 5 seconds or so...
                        if (!Video.IsActive && !Video.Restart())
                        {
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        Xbox.Connect();
                        Video.Restart();
                    }
                    Application.DoEvents();
                }
                TimeSpan elapse = DateTime.Now - before;
                double   fps    = counter / elapse.TotalSeconds;

                Xbox.Disconnect();
                renderWindow.Image = null;
                mnuPause.Checked   = false;
                mnuStep.Enabled    = false;
                status.Text        = "Disconnected";
            }
            catch (Exception)
            {
            }

            renderWindow.Image = GetDefaultImage();
        }
示例#2
0
 void LiveStreamLoop()
 {
     LiveStreamRunning = true;
     while (LiveStreamRunning)
     {
         if (videoStream.IsActive)
         {
             lock (XBoxIO.XBox)
             {
                 imageBox.BackgroundImage = videoStream.NextFrame();
             }
         }
         else if (LiveStreamPaused == false)
         {
             ResumeStream();
         }
     }
 }
示例#3
0
        static void LiveStream(object pictureBox)
        {
            PictureBox imageBox = (PictureBox)pictureBox;

            Program.XBox.SetFileCacheSize(1);
            XboxVideoStream xvs = new XboxVideoStream(Program.XBox, XboxVideoStream.VideoSize.Medium, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.Immediate);

            LiveStreamRunning = true;
            xvs.Begin();
            while (LiveStreamRunning)
            {
                Waiter.Reset();
                imageBox.BackgroundImage = xvs.NextFrame();//imageBox.BackgroundImage = Program.XBox.Screenshot();
                Waiter.Set();
                Pauser.WaitOne();
            }
            xvs.End();
            Program.ScreenshotTool.checkLiveStream.Checked = false;
        }