private void TestSeek()
        {
            int  hr;
            long t;

            hr = m_mms.Seek(43200000 / 2);
            MsError.ThrowExceptionForHR(hr);

            hr = m_mms.GetTime(out t);
            MsError.ThrowExceptionForHR(hr);

            Debug.Assert(t == 43200000 / 2, "Seek/GetTime");
        }
        private void TestStateAndEOS()
        {
            int              hr;
            IntPtr           pEOS;
            StreamState      pState;
            ManualResetEvent mre = new ManualResetEvent(false);

            ////////////////
            /// The AddMediaStream does something that prevents playback (I don't
            /// know what).  Create a new stream to do the actual run.
            IAMMultiMediaStream amms = (IAMMultiMediaStream) new AMMultiMediaStream();

            hr = amms.OpenFile("foo.avi", AMOpenModes.RenderAllStreams);
            MsError.ThrowExceptionForHR(hr);
            IMultiMediaStream mms = amms as IMultiMediaStream;

            ////////////////

            hr = mms.GetEndOfStreamEventHandle(out pEOS);
            MsError.ThrowExceptionForHR(hr);

            mre.SafeWaitHandle = new Microsoft.Win32.SafeHandles.SafeWaitHandle(pEOS, true);

            hr = mms.Seek(0);
            MsError.ThrowExceptionForHR(hr);

            hr = mms.GetState(out pState);
            MsError.ThrowExceptionForHR(hr);

            Debug.Assert(pState == StreamState.Stop, "GetState");

            hr = mms.SetState(StreamState.Run);
            MsError.ThrowExceptionForHR(hr);

            hr = mms.GetState(out pState);
            MsError.ThrowExceptionForHR(hr);

            Debug.Assert(pState == StreamState.Run, "GetState2");

            bool b = mre.WaitOne(1000 * 6, false);

            Debug.Assert(b, "WaitOne");

            mre.Close();
            Marshal.ReleaseComObject(mms);
        }