protected override double GetMediaPosition()
        {
            double val = 0;

            if (mediaPosition != null)
            {
                int hr = mediaPosition.get_CurrentPosition(out val);
                DsError.ThrowExceptionForHR(hr);
            }

            return(val * durationScaleFactor);
        }
Esempio n. 2
0
        public double GetCurrentPosition()
        {
            double result = 0;

            m_mediaPosition.get_CurrentPosition(out result);
            return(result);
        }
        public override void SeekRelative(double dTime)
        {
            if (m_state != PlayState.Init)
            {
                if (mediaCtrl != null && mediaPos != null)
                {
                    double dCurTime;
                    mediaPos.get_CurrentPosition(out dCurTime);

                    dTime = dCurTime + dTime;
                    if (dTime < 0.0d)
                    {
                        dTime = 0.0d;
                    }
                    if (dTime < Duration)
                    {
                        mediaPos.put_CurrentPosition(dTime);
                    }
                }
            }
        }
        void TestPosition()
        {
            int hr;

            double pllTime;

            Thread.Sleep(1500);

            hr = m_mediaPosition.get_CurrentPosition(out pllTime);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pllTime > 1.0, "get_CurrentPosition");

            hr = m_mediaPosition.put_CurrentPosition(0);
            DsError.ThrowExceptionForHR(hr);

            hr = m_mediaPosition.get_CurrentPosition(out pllTime);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pllTime < 1.0, "get_CurrentPosition");
        }
Esempio n. 5
0
 //
 //handler to update the Position label and move the trackbar
 //tick postion, we set isTimer to true, then changing the
 //trackbar Value property will generate a call to the ValueChanged
 //handler but we don't want to seek the filter, so ValueChanged
 //check if isTimer is true and ignore timer update to seek the filter
 //
 private void timer1_Tick(object sender, System.EventArgs e)
 {
     if (isSeeking)
     {
         isTimer = true;
         double currentPosition;
         mediaPos.get_CurrentPosition(out currentPosition);
         trackBar1.Value = (int)(currentPosition * 100.0);
         isTimer         = false;
         minutes         = (int)currentPosition / 60;
         seconds         = (int)currentPosition % 60;
         label1.Text     = "Position: " + minutes.ToString("D2")
                           + ":m" + seconds.ToString("D2") + ":s";
     }
 }
Esempio n. 6
0
        //set the trackBar1'value equel the video'progress
        private void updateTimeBarThread()
        {
            double time;
            int    volu;

            while (true)
            {
                mediaPosition.get_CurrentPosition(out time);
                Console.WriteLine(time);
                basicAudio.get_Volume(out volu);
                Console.WriteLine(volu);
                this.BeginInvoke(new MethodInvoker(() =>
                {
                    trackBar1.Value = (int)time;
                }));
                Thread.Sleep(1000);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Queries the current video source for its capabilities regarding seeking and time info.
        /// The graph should be fully constructed for accurate information
        /// </summary>
        protected void QuerySeekingCapabilities()
        {
            try
            {
                _mediaSeeking.SetTimeFormat(TimeFormat.MediaTime);
                //get capabilities from the graph, and see what it supports that interests us
                AMSeekingSeekingCapabilities caps;
                int    r       = _mediaSeeking.GetCapabilities(out caps);
                long   lTest   = 0;
                double dblTest = 0;
                if (r != 0)
                {
                    _seek_canGetCurrentPos = false;
                    _seek_canSeek          = false;
                    _seek_canGetDuration   = false;
                }
                else    //if we were able to read the capabilities, then determine if the capability works, both by checking the
                // advertisement, and actually trying it out.
                {
                    _seek_canSeek = ((caps & AMSeekingSeekingCapabilities.CanSeekAbsolute) == AMSeekingSeekingCapabilities.CanSeekAbsolute) &&
                                    (_mediaSeeking.SetPositions(0, AMSeekingSeekingFlags.AbsolutePositioning,
                                                                null, AMSeekingSeekingFlags.NoPositioning) == 0);

                    _seek_canGetDuration = ((caps & AMSeekingSeekingCapabilities.CanGetDuration) == AMSeekingSeekingCapabilities.CanGetDuration) &&
                                           (_mediaSeeking.GetDuration(out lTest) == 0);

                    _seek_canGetCurrentPos = ((caps & AMSeekingSeekingCapabilities.CanGetCurrentPos) == AMSeekingSeekingCapabilities.CanGetCurrentPos) &&
                                             (_mediaSeeking.GetCurrentPosition(out lTest) == 0);
                }

                //check capabilities for the IMediaPosition interface
                _pos_canSeek          = (_mediaPosition.put_CurrentPosition(0) == 0);
                _pos_canGetDuration   = (_mediaPosition.get_Duration(out dblTest) == 0);
                _pos_canGetCurrentPos = (_mediaPosition.get_CurrentPosition(out dblTest) == 0);
            }
            catch (Exception)
            {
                _seek_canSeek = false;
                _pos_canSeek  = false;
            }
        }