コード例 #1
0
ファイル: MpcApi.cs プロジェクト: glxxyz/classicsub
        protected void ExitMPCApiApp()
        {
            // kill the thread nicely
            PollThreadQuit = true;
            GetCurrentPosEvent.Set();

            // Kill the app
            //Application.Exit();
        }
コード例 #2
0
ファイル: MpcApi.cs プロジェクト: glxxyz/classicsub
        public void ResyncTime()
        {
            if (!needToDoResyncs)
            {
                SendGetCurrentPosition();
                return;
            }

            // Only attempt a resync if a video is currently playing
            if (VideoCurrentlyPlaying)
            {
                LastResyncMs = -2;
                GetCurrentPosEvent.Set();
            }
        }
コード例 #3
0
ファイル: MpcApi.cs プロジェクト: glxxyz/classicsub
        void ContinueResync(int currentPos)
        {
            if (!needToDoResyncs)
            {
                return;
            }

            int      adjustedPos = currentPos;
            DateTime now         = DateTime.UtcNow;

            if (LastResyncMs == -1)
            {
                // Ignore: a resync wasn't started
            }
            else if (LastResyncMs == -2)
            {
                // We are just starting a resync
                LastResyncMs      = currentPos;
                ResyncStartedTime = DateTime.UtcNow;
                GetCurrentPosEvent.Set();
            }
            else
            {
                if (currentPos == LastResyncMs)
                {
                    // Time is the same; continue polling
                    GetCurrentPosEvent.Set();

                    // Adjust time to a better estimate, we can add on the time that has elapsed during
                    // the resync
                    TimeSpan diff   = now.Subtract(ResyncStartedTime);
                    int      diffMs = (int)diff.TotalMilliseconds;
                    adjustedPos += Math.Max(diffMs, 0);
                }
                else
                {
                    // Time is different, we now have an accurate time, no need to continue
                    LastResyncMs = -1;
                }
            }

            LastReportedDateTime   = now;
            LastReportedPositionMs = adjustedPos;
            PausedPositionMs       = adjustedPos;
        }