void TestRate()
        {
            int    hr;
            double rate;

            hr = m_mediaPosition.get_Rate(out rate);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(rate > 0 && rate < 2, "get_Rate");

            hr = m_mediaPosition.put_Rate(2.0);
            DsError.ThrowExceptionForHR(hr);

            hr = m_mediaPosition.get_Rate(out rate);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(rate > 1 && rate < 3, "get_Rate");

            hr = m_mediaPosition.put_Rate(1.0);
            DsError.ThrowExceptionForHR(hr);
        }
Example #2
0
        /// <summary>
        /// Modify the playback rate.
        /// </summary>
        /// <param name="dRateAdjust">The rate to adjust by.</param>
        private void ModifyRate(double dRateAdjust)
        {
            int    hr = 0;
            double dRate;

            // If the IMediaPosition interface exists, use it to set rate
            if ((_mediaPosition != null) && (dRateAdjust != 0.0))
            {
                hr = _mediaPosition.get_Rate(out dRate);
                if (hr == 0)
                {
                    // Add current rate to adjustment value
                    double dNewRate = dRate + dRateAdjust;
                    hr = _mediaPosition.put_Rate(dNewRate);

                    // Save global rate
                    if (hr == 0)
                    {
                        _currentPlaybackRate = dNewRate;
                    }
                }
            }
        }
Example #3
0
        void ModifyRate(double rateAdjust)
        {
            try
            {
                if ((mediaPos == null) || (rateAdjust == 0.0))
                {
                    return;
                }

                double rate;
                int    hr = mediaPos.get_Rate(out rate);
                if (hr < 0)
                {
                    return;
                }
                rate += rateAdjust;
                hr    = mediaPos.put_Rate(rate);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }