示例#1
0
        protected void UpdateCurrentPosition()
        {
            if (_mediaSeeking == null)
            {
                return;
            }
            //GetCurrentPosition(): Returns stream position.
            //Stream position:The current playback position, relative to the content start
            long   lStreamPos;
            double fCurrentPos;

            _mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position
            fCurrentPos  = lStreamPos;
            fCurrentPos /= 10000000d;
            _currentPos  = fCurrentPos;

            long   lContentStart, lContentEnd;
            double fContentStart, fContentEnd;

            _mediaSeeking.GetAvailable(out lContentStart, out lContentEnd);
            //_mediaSeeking.GetDuration(out  lDuration);
            //mediaPos.get_Duration(out duration);

            fContentStart  = lContentStart;
            fContentEnd    = lContentEnd;
            fContentStart /= 10000000d;
            fContentEnd   /= 10000000d;
            //duration=lDuration;
            //duration /= 10000000d;
            //Log.Info("{0} {1} {2}  ({3}) {4} {5}", fCurrentPos, fContentStart, fContentEnd, _currentPos, lDuration,duration);
            fContentEnd -= fContentStart;
            _duration    = fContentEnd;
        }
示例#2
0
        /// <summary>
        /// Test the functions that read the current position
        /// </summary>
        void TestPosition()
        {
            int  hr;
            long pCurrent1, pStop1, pDuration1;
            long pCurrent2, pStop2;
            long pEarliest, pLatest;

            // Read the current play position
            hr = m_ims.GetCurrentPosition(out pCurrent1);
            Marshal.ThrowExceptionForHR(hr);

            // Read the current stop position
            hr = m_ims.GetStopPosition(out pStop1);
            Marshal.ThrowExceptionForHR(hr);

            // Read the duraton (probably related to StopPosition - Position
            hr = m_ims.GetDuration(out pDuration1);
            Marshal.ThrowExceptionForHR(hr);

            // Read both current and stop positions
            hr = m_ims.GetPositions(out pCurrent2, out pStop2);
            Marshal.ThrowExceptionForHR(hr);

            // Get the cached range of values
            hr = m_ims.GetAvailable(out pEarliest, out pLatest);
            Marshal.ThrowExceptionForHR(hr);

            // Since we aren't playing, current should be 0, stop &
            // duration should be the same (the length of the clip)
            Debug.Assert(pCurrent1 == 0, "CurrentPosition");
            Debug.Assert(pStop1 == pDuration1, "Stop, Duration");
            Debug.Assert(pCurrent1 == pCurrent2, "GetPositions");
            Debug.Assert(pStop1 == pStop2, "CurrentPosition stop");
            Debug.Assert(pEarliest == pCurrent1, "CurrentPosition stop");
            Debug.Assert(pLatest == pStop2, "CurrentPosition stop");
        }