void TestPlayBackwards()
        {
            int     hr;
            IDvdCmd ppCmd = null;
            DvdPlaybackLocation2 pLocation;

            AllowPlay();
            hr = m_idc2.PlayTitle(2, DvdCmdFlags.Flush | DvdCmdFlags.SendEvents, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            Thread.Sleep(100);

            hr = m_idc2.PlayBackwards(1, DvdCmdFlags.Flush | DvdCmdFlags.SendEvents, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            // S_False means it can't play backwards (I'm guessing)
            if (hr != 1)
            {
                Thread.Sleep(2000);

                hr = m_idi2.GetCurrentLocation(out pLocation);
                DsError.ThrowExceptionForHR(hr);

                Debug.Assert(pLocation.TimeCode.bSeconds == 0, "TestPlayBackwards");
            }

            hr = m_idc2.Stop();
            DsError.ThrowExceptionForHR(hr);
        }
        // Media events are sent to use as windows messages.  Used to test GetCmdFromEvent
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            // If this is a windows media message
            case WM_GRAPHNOTIFY:
                EventCode eventCode;
                IntPtr    p1, p2;
                int       hr;

                hr = m_mediaEvent.GetEvent(out eventCode, out p1, out p2, 0);
                while (hr == 0)
                {
                    switch (eventCode)
                    {
                    case EventCode.DvdCmdEnd:
                    {
                        IDvdCmd pCmdObj = null;

                        hr = this.m_idi2.GetCmdFromEvent(p1, out pCmdObj);
                        Debug.WriteLine(String.Format("{0} status1", hr));
                        // Handle the event.
                        Debug.WriteLine(eventCode);
                        break;
                    }

                    case EventCode.DvdCmdStart:
                    {
                        IDvdCmd pCmdObj = null;

                        hr = this.m_idi2.GetCmdFromEvent(p1, out pCmdObj);
                        Debug.WriteLine(String.Format("{0} status2", hr));
                        // Handle the event.
                        Debug.WriteLine(eventCode);
                        break;
                    }

                    default:
                    {
                        Debug.WriteLine(eventCode);
                        break;
                    }
                    }

                    // Release parms
                    m_mediaEvent.FreeEventParams(eventCode, p1, p2);

                    // check for additional events
                    hr = m_mediaEvent.GetEvent(out eventCode, out p1, out p2, 0);
                }
                break;

            // All other messages
            default:
                // unhandled window message
                base.WndProc(ref m);
                break;
            }
        }
Exemple #3
0
        void TestWaitForStart()
        {
            int     hr;
            IDvdCmd ppCmd = null;

            AllowPlay();
            hr = m_idc2.PlayTitle(2, DvdCmdFlags.Flush | DvdCmdFlags.SendEvents, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            // Only takes fraction of a second
            hr = ppCmd.WaitForStart();
            DsError.ThrowExceptionForHR(hr);

            hr = m_idc2.Stop();
            DsError.ThrowExceptionForHR(hr);
        }
Exemple #4
0
        void TestWaitForEnd()
        {
            int     hr;
            IDvdCmd ppCmd = null;

            AllowPlay();
            hr = m_idc2.PlayTitle(2, DvdCmdFlags.Flush | DvdCmdFlags.SendEvents, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            // Only takes fraction of a second.  Does NOT wait for title to finish.  Only waits
            // for Graph to finish processing command.
            hr = ppCmd.WaitForEnd();
            DsError.ThrowExceptionForHR(hr);

            hr = m_idc2.Stop();
            DsError.ThrowExceptionForHR(hr);
        }
Exemple #5
0
        void TestGetCurrent()
        {
            int          hr;
            IDvdCmd      ppCmd = null;
            int          pulAnglesAvailable;
            int          pulCurrentAngle;
            int          pulStreamsAvailable;
            int          pulCurrentStream;
            int          pulSubAvailable;
            int          pulCurrentSub;
            bool         pbIsDisabled;
            ValidUOPFlag pulUOPs;

            AllowPlay();
            hr = m_idc2.PlayTitle(2, DvdCmdFlags.Flush, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            hr = m_idi2.GetCurrentAngle(out pulAnglesAvailable, out pulCurrentAngle);
            DsError.ThrowExceptionForHR(hr);

            hr = m_idi2.GetCurrentAudio(out pulStreamsAvailable, out pulCurrentStream);
            DsError.ThrowExceptionForHR(hr);

            hr = m_idi2.GetCurrentSubpicture(out pulSubAvailable, out pulCurrentSub, out pbIsDisabled);
            DsError.ThrowExceptionForHR(hr);

            hr = m_idi2.GetCurrentUOPS(out pulUOPs);
            DsError.ThrowExceptionForHR(hr);

            hr = m_idc2.Stop();
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pulAnglesAvailable == 1, "GetCurrentAngle");
            Debug.Assert(pulCurrentAngle == 1, "GetCurrentAngle2");

            Debug.Assert(pulStreamsAvailable == 1, "GetCurrentAudio");
            Debug.Assert(pulCurrentStream == 0, "GetCurrentAudio2");

            Debug.Assert(pulSubAvailable == 0, "GetCurrentSubpicture");
            //Debug.Assert(pulCurrentSub == 1, "GetCurrentSubpicture2");
            Debug.Assert(pbIsDisabled, "GetCurrentSubpicture3");

            Debug.Assert(pulUOPs == 0);
        }
Exemple #6
0
        void TestButton()
        {
            int     hr;
            int     pulButtonIndex;
            IDvdCmd ppCmd = null;

            hr = m_idc2.ShowMenu(DvdMenuId.Title, DvdCmdFlags.Flush, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            DsRect pRect = new DsRect();

            hr = m_idi2.GetButtonRect(1, pRect);
            //ThrowExceptionForHR(hr);

            hr = m_idi2.GetButtonAtPosition(new Point(130, 130), out pulButtonIndex);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pulButtonIndex == 1, "TestButton");
        }
        void TestPlayTitle()
        {
            int     hr;
            IDvdCmd ppCmd = null;
            DvdPlaybackLocation2 pLocation;

            AllowPlay();
            hr = m_idc2.PlayTitle(2, DvdCmdFlags.Flush | DvdCmdFlags.SendEvents, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            Thread.Sleep(2000);

            hr = m_idi2.GetCurrentLocation(out pLocation);
            DsError.ThrowExceptionForHR(hr);

            hr = m_idc2.Stop();
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pLocation.TitleNum == 2, "PlayTitle");
        }
Exemple #8
0
        // Get past all the menus to a point where titles can be played.
        void AllowPlay()
        {
            int       hr;
            int       buttonavail, curbutton;
            IDvdCmd   ppCmd = null;
            DvdDomain dvdd;

            hr = m_idi2.GetCurrentDomain(out dvdd);
            DsError.ThrowExceptionForHR(hr);

            if (dvdd == DvdDomain.Stop)
            {
                hr = m_idc2.Resume(DvdCmdFlags.Flush, out ppCmd);
                if (hr < 0)
                {
                    hr = m_idc2.ShowMenu(DvdMenuId.Title, DvdCmdFlags.Flush, out ppCmd);
                    DsError.ThrowExceptionForHR(hr);
                }
            }

            while ((hr = m_idi2.GetCurrentDomain(out dvdd)) == 0 &&
                   ((dvdd == DvdDomain.VideoManagerMenu) || (dvdd == DvdDomain.VideoTitleSetMenu)))
            {
                hr = m_idi2.GetCurrentButton(out buttonavail, out curbutton);
                DsError.ThrowExceptionForHR(hr);

                if (curbutton > 0)
                {
                    hr = m_idc2.SelectAndActivateButton(1);
                    DsError.ThrowExceptionForHR(hr);
                }

                Thread.Sleep(500);
            }

            DsError.ThrowExceptionForHR(hr);

            hr = m_idc2.Stop();
            DsError.ThrowExceptionForHR(hr);
        }
Exemple #9
0
        void TestGetTotalTitleTime()
        {
            int              hr;
            IDvdCmd          ppCmd = null;
            DvdHMSFTimeCode  dhtc  = new DvdHMSFTimeCode();
            DvdTimeCodeFlags dtcf  = new DvdTimeCodeFlags();

            AllowPlay();

            hr = m_idc2.PlayTitle(2, DvdCmdFlags.Flush, out ppCmd);
            DsError.ThrowExceptionForHR(hr);

            Thread.Sleep(500);

            hr = m_idi2.GetTotalTitleTime(dhtc, out dtcf);
            DsError.ThrowExceptionForHR(hr);

            hr = m_idc2.Stop();
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(dhtc.bFrames == 13, "GetTotalTitleTime");
            Debug.Assert(dhtc.bSeconds == 12, "GetTotalTitleTime2");
            Debug.Assert(dtcf == DvdTimeCodeFlags.FPS30, "GetTotalTitleTime3");
        }
Exemple #10
0
        /// <summary>
        /// Called when an asynchronous DVD command is completed.
        /// </summary>
        /// <param name="p1">The command event handle.</param>
        private void OnCmdComplete(IntPtr p1)
        {
            try
            {
                ServiceRegistration.Get <ILogger>().Debug("DVD OnCmdComplete");
                if (!_pendingCmd || _dvdInfo == null)
                {
                    return;
                }

                IDvdCmd cmd;
                int     hr = _dvdInfo.GetCmdFromEvent(p1, out cmd);
                if (hr != 0 || cmd == null)
                {
                    ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DVD OnCmdComplete GetCmdFromEvent failed");
                    return;
                }

                if (cmd != _cmdOption)
                {
                    ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DVD OnCmdComplete UNKNOWN CMD!!!");
                    Marshal.ReleaseComObject(cmd);
                    return;
                }

                Marshal.ReleaseComObject(cmd);
                Marshal.ReleaseComObject(_cmdOption);
                _cmdOption  = null;
                _pendingCmd = false;
                ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DVD OnCmdComplete OK.");
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: OnCmdComplete() {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
            }
        }
        /// <summary> asynchronous command completed </summary>
        void OnCmdComplete( IntPtr p1, IntPtr hrg )
        {
            // Trace.WriteLine( "DVD OnCmdComplete.........." );
            if( (pendingCmd == false) || (dvdInfo == null) )
            {
                return;
            }

            IDvdCmd		cmd;
            int hr = dvdInfo.GetCmdFromEvent( p1, out cmd );
            DsError.ThrowExceptionForHR(hr);

            if( cmd == null)
            {
                // DVD OnCmdComplete GetCmdFromEvent failed
                return;
            }

            if( cmd != cmdOption )
            {
                // DVD OnCmdComplete UNKNOWN CMD
                Marshal.ReleaseComObject( cmd );
                cmd = null;
                return;
            }

            Marshal.ReleaseComObject( cmd );
            cmd = null;
            Marshal.ReleaseComObject( cmdOption );
            cmdOption = null;
            pendingCmd = false;
            // Trace.WriteLine( "DVD OnCmdComplete OK." );
            UpdateMenu();
        }
        /// <summary> do cleanup and release DirectShow. </summary>
        void CloseInterfaces()
        {
            int hr;
            try
            {
                if( dvdCtrl != null )
                {
                    hr = dvdCtrl.SetOption( DvdOptionFlag.ResetOnStop, true );
                }

                if( mediaCtrl != null )
                {
                    hr = mediaCtrl.Stop();
                    mediaCtrl = null;
                }
                playState = PlayState.Stopped;

                if( mediaEvt != null )
                {
                    hr = mediaEvt.SetNotifyWindow( IntPtr.Zero, WM_DVD_EVENT, IntPtr.Zero );
                    mediaEvt = null;
                }

                if( videoWin != null )
                {
                    hr = videoWin.put_Visible( OABool.False );
                    hr = videoWin.put_MessageDrain( IntPtr.Zero );
                    hr = videoWin.put_Owner( IntPtr.Zero );
                    videoWin = null;
                }

                videoStep	= null;

                if( cmdOption != null )
                {
                    Marshal.ReleaseComObject( cmdOption );
                    cmdOption = null;
                }

                pendingCmd = false;

                if( graphBuilder != null )
                {
                    Marshal.ReleaseComObject( graphBuilder );
                    graphBuilder = null;
                }

                dvdCtrl		= null;
                if( dvdInfo != null )
                {
                    Marshal.ReleaseComObject( dvdInfo );
                    dvdInfo = null;
                }

                if( dvdGraph != null )
                {
                    Marshal.ReleaseComObject( dvdGraph );
                    dvdGraph = null;
                }

                playState = PlayState.Init;
            }
            catch( Exception )
            {}
        }
    /// <summary> asynchronous command completed </summary>
    private void OnCmdComplete(int p1, int hrg)
    {
      try
      {
        //				Log.Info( "DVD OnCmdComplete.........." );
        if ((_pendingCmd == false) || (_dvdInfo == null))
        {
          return;
        }

        IDvdCmd cmd;
        int hr = _dvdInfo.GetCmdFromEvent(p1, out cmd);
        if ((hr != 0) || (cmd == null))
        {
          Log.Error("DVDPlayer:OnCmdComplete() GetCmdFromEvent failed!");
          return;
        }

        if (cmd != _cmdOption)
        {
          Log.Error("DVDPlayer:OnCmdComplete() Unknown command!");
          DirectShowUtil.ReleaseComObject(cmd);
          cmd = null;
          return;
        }

        DirectShowUtil.ReleaseComObject(cmd);
        cmd = null;
        DirectShowUtil.ReleaseComObject(_cmdOption);
        _cmdOption = null;
        _pendingCmd = false;
        //				Log.Info( "DVD OnCmdComplete OK." );
        UpdateMenu();
      }
      catch (Exception ex)
      {
        Log.Error("DVDPlayer:OnCmdComplete() {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
      }
    }
    /// <summary> do cleanup and release DirectShow. </summary>
    protected virtual void CloseInterfaces()
    {
      if (_graphBuilder == null)
      {
        return;
      }
      int hr;
      try
      {
        Log.Info("DVDPlayer:cleanup DShow graph");

        if (_mediaCtrl != null)
        {
          hr = _mediaCtrl.Stop();
          _mediaCtrl = null;
        }
        _state = PlayState.Stopped;
        VMR9Util.g_vmr9.EVRSetDVDMenuState(false);

        _mediaEvt = null;
        _visible = false;
        _videoWin = null;
        //				videoStep	= null;
        _dvdCtrl = null;
        _dvdInfo = null;
        _basicVideo = null;
        _basicAudio = null;
        _mediaPos = null;

        if (_dvdbasefilter != null)
        {
          while ((hr = DirectShowUtil.ReleaseComObject(_dvdbasefilter)) > 0)
          {
            ;
          }
          _dvdbasefilter = null;
        }

        if (_cmdOption != null)
        {
          DirectShowUtil.ReleaseComObject(_cmdOption);
        }
        _cmdOption = null;
        _pendingCmd = false;
        if (_line21Decoder != null)
        {
          while ((hr = DirectShowUtil.ReleaseComObject(_line21Decoder)) > 0)
          {
            ;
          }
          _line21Decoder = null;
        }


        if (_graphBuilder != null)
        {
          DirectShowUtil.RemoveFilters(_graphBuilder);
          if (_rotEntry != null)
          {
            _rotEntry.SafeDispose();
            _rotEntry = null;
          }
          while ((hr = DirectShowUtil.ReleaseComObject(_graphBuilder)) > 0)
          {
            ;
          }
          _graphBuilder = null;
        }

        if (_dvdGraph != null)
        {
          while ((hr = DirectShowUtil.ReleaseComObject(_dvdGraph)) > 0)
          {
            ;
          }
          _dvdGraph = null;
        }
        _state = PlayState.Init;

        GUIGraphicsContext.form.Invalidate(true);
        GUIGraphicsContext.form.Activate();
      }
      catch (Exception ex)
      {
        Log.Error("DVDPlayer:exception while cleanuping DShow graph {0} {1}", ex.Message, ex.StackTrace);
      }
    }
        private void OnDvdCmdComplete(IntPtr evParam1, IntPtr evParam2)
        {
            IDvdInfo2 dvdInfo = _sourceFilter as IDvdInfo2;

            if ((_pendingDvdCmd == false) || (dvdInfo == null))
            {
                return;
            }

            IDvdCmd cmd = null;
            int hr = dvdInfo.GetCmdFromEvent(evParam1, out cmd);
            DsError.ThrowExceptionForHR(hr);

            if (cmd == null)
            {
                // DVD OnCmdComplete GetCmdFromEvent failed
                return;
            }

            if (cmd != _mDvdCmdOption)
            {
                // DVD OnCmdComplete UNKNOWN CMD
                Marshal.ReleaseComObject(cmd);
                cmd = null;
                return;
            }

            Marshal.ReleaseComObject(cmd);
            cmd = null;
            Marshal.ReleaseComObject(_mDvdCmdOption);
            _mDvdCmdOption = null;
            _pendingDvdCmd = false;
        }
Exemple #16
0
        /// <summary> do cleanup and release DirectShow. </summary>
        protected virtual void CloseDVDInterfaces()
        {
            if (_graphBuilder == null)
            {
                return;
            }
            int hr;
            try
            {
                logger.Info("DVDPlayer:cleanup DShow graph");

                if (_mediaCtrl != null)
                {
                    hr = _mediaCtrl.Stop();
                    _mediaCtrl = null;
                }
                _state = PlayState.Stopped;

                _mediaEvt = null;
                _visible = false;
                _videoWin = null;
                //				videoStep	= null;
                _dvdCtrl = null;
                _dvdInfo = null;
                _basicVideo = null;
                _basicAudio = null;
                _mediaPos = null;
                _mediaSeek = null;
                _mediaStep = null;

                //if (_vmr7 != null)
                //{
                //    _vmr7.RemoveVMR7();
                //}
                //_vmr7 = null;

                if (_vmr9Filter != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_vmr9Filter)) > 0)
                    {
                        ;
                    }
                    _vmr9Filter = null;
                }

                if (_dvdbasefilter != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_dvdbasefilter)) > 0)
                    {
                        ;
                    }
                    _dvdbasefilter = null;
                }

                if (_cmdOption != null)
                {
                    DirectShowUtil.ReleaseComObject(_cmdOption);
                }
                _cmdOption = null;
                _pendingCmd = false;
                if (_line21Decoder != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_line21Decoder)) > 0)
                    {
                        ;
                    }
                    _line21Decoder = null;
                }

                if (_graphBuilder != null)
                {
                    DirectShowUtil.RemoveFilters(_graphBuilder);
                    if (_rotEntry != null)
                    {
                        _rotEntry.Dispose();
                        _rotEntry = null;
                    }
                    while ((hr = DirectShowUtil.ReleaseComObject(_graphBuilder)) > 0)
                    {
                        ;
                    }
                    _graphBuilder = null;
                }

                if (_dvdGraph != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_dvdGraph)) > 0)
                    {
                        ;
                    }
                    _dvdGraph = null;
                }
                _state = PlayState.Init;

            }
            catch (Exception ex)
            {
                logger.Error("DVDPlayer:exception while cleanuping DShow graph {0} {1}", ex.Message, ex.StackTrace);
            }
        }
Exemple #17
0
    /// <summary>
    /// Called when an asynchronous DVD command is completed.
    /// </summary>
    /// <param name="p1">The command event handle.</param>
    private void OnCmdComplete(IntPtr p1)
    {
      try
      {
        ServiceRegistration.Get<ILogger>().Debug("DVD OnCmdComplete");
        if (!_pendingCmd || _dvdInfo == null)
          return;

        IDvdCmd cmd;
        int hr = _dvdInfo.GetCmdFromEvent(p1, out cmd);
        if (hr != 0 || cmd == null)
        {
          ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DVD OnCmdComplete GetCmdFromEvent failed");
          return;
        }

        if (cmd != _cmdOption)
        {
          ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DVD OnCmdComplete UNKNOWN CMD!!!");
          Marshal.ReleaseComObject(cmd);
          return;
        }

        Marshal.ReleaseComObject(cmd);
        Marshal.ReleaseComObject(_cmdOption);
        _cmdOption = null;
        _pendingCmd = false;
        ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DVD OnCmdComplete OK.");
      }
      catch (Exception ex)
      {
        ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: OnCmdComplete() {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
      }
    }
Exemple #18
0
        /// <summary> do cleanup and release DirectShow. </summary>
        protected virtual void CloseDVDInterfaces()
        {
            if (_graphBuilder == null)
            {
                return;
            }
            int hr;

            try
            {
                logger.Info("DVDPlayer:cleanup DShow graph");

                if (_mediaCtrl != null)
                {
                    hr         = _mediaCtrl.Stop();
                    _mediaCtrl = null;
                }
                _state = PlayState.Stopped;

                _mediaEvt = null;
                _visible  = false;
                _videoWin = null;
                //				videoStep	= null;
                _dvdCtrl    = null;
                _dvdInfo    = null;
                _basicVideo = null;
                _basicAudio = null;
                _mediaPos   = null;
                _mediaSeek  = null;
                _mediaStep  = null;

                //if (_vmr7 != null)
                //{
                //    _vmr7.RemoveVMR7();
                //}
                //_vmr7 = null;



                if (_vmr9Filter != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_vmr9Filter)) > 0)
                    {
                        ;
                    }
                    _vmr9Filter = null;
                }

                if (_dvdbasefilter != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_dvdbasefilter)) > 0)
                    {
                        ;
                    }
                    _dvdbasefilter = null;
                }

                if (_cmdOption != null)
                {
                    DirectShowUtil.ReleaseComObject(_cmdOption);
                }
                _cmdOption  = null;
                _pendingCmd = false;
                if (_line21Decoder != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_line21Decoder)) > 0)
                    {
                        ;
                    }
                    _line21Decoder = null;
                }


                if (_graphBuilder != null)
                {
                    DirectShowUtil.RemoveFilters(_graphBuilder);
                    if (_rotEntry != null)
                    {
                        _rotEntry.Dispose();
                        _rotEntry = null;
                    }
                    while ((hr = DirectShowUtil.ReleaseComObject(_graphBuilder)) > 0)
                    {
                        ;
                    }
                    _graphBuilder = null;
                }

                if (_dvdGraph != null)
                {
                    while ((hr = DirectShowUtil.ReleaseComObject(_dvdGraph)) > 0)
                    {
                        ;
                    }
                    _dvdGraph = null;
                }
                _state = PlayState.Init;
            }
            catch (Exception ex)
            {
                logger.Error("DVDPlayer:exception while cleanuping DShow graph {0} {1}", ex.Message, ex.StackTrace);
            }
        }
Exemple #19
0
        private void CloseInterfaces()
        {
            int hr = 0;

            try
            {
                lock (this)
                {
                    // Relinquish ownership (IMPORTANT!) after hiding video window
                    //if (!this.isAudioOnly)
                    //{
                    //    hr = this.videoWindow.put_Visible(OABool.False);
                    //    DsError.ThrowExceptionForHR(hr);
                    //    hr = this.videoWindow.put_Owner(IntPtr.Zero);
                    //    DsError.ThrowExceptionForHR(hr);
                    //}

                    //#if DEBUG
                    try
                    {
                        if (rot != null)
                        {
                            rot.Dispose();
                            rot = null;
                        }
                    }
                    catch { }
                    //#endif

                    if (dvdSubtitle != null)
                        Marshal.ReleaseComObject(dvdSubtitle);
                    dvdSubtitle = null;

                    if (dvdCtrl != null)
                    {
                        hr = dvdCtrl.SetOption(DvdOptionFlag.ResetOnStop, true);
                    }

                    if (cmdOption != null)
                    {
                        Marshal.ReleaseComObject(cmdOption);
                        cmdOption = null;
                    }

                    pendingCmd = false;

                    dvdCtrl = null;
                    if (dvdInfo != null)
                    {
                        Marshal.ReleaseComObject(dvdInfo);
                        dvdInfo = null;
                    }

                    if (this.mediaEventEx != null)
                    {
                        if (dvdGraph != null)
                            hr = this.mediaEventEx.SetNotifyWindow(IntPtr.Zero, WM.DVD_EVENT, IntPtr.Zero);
                        else
                            hr = this.mediaEventEx.SetNotifyWindow(IntPtr.Zero, WM.NULL, IntPtr.Zero);
                        //DsError.ThrowExceptionForHR(hr);
                    }

                    if (evrDisplay != null)
                    {
                        //evrDisplay.SetVideoWindow(IntPtr.Zero);
                        Marshal.ReleaseComObject(evrDisplay);
                    }
                    evrDisplay = null;
                    if (this.evrRenderer != null)
                        Marshal.ReleaseComObject(evrRenderer);
                    evrRenderer = null;

                    // Release and zero DirectShow interfaces
                    if (this.mediaEventEx != null)
                        this.mediaEventEx = null;
                    if (this.mediaSeeking != null)
                        this.mediaSeeking = null;
                    if (this.mediaPosition != null)
                        this.mediaPosition = null;
                    if (this.mediaControl != null)
                        this.mediaControl = null;
                    if (this.basicAudio != null)
                        this.basicAudio = null;
                    if (this.basicVideo != null)
                        this.basicVideo = null;
                    //if (this.videoWindow != null)
                    //    this.videoWindow = null;
                    if (this.frameStep != null)
                        this.frameStep = null;
                    if (this.graphBuilder != null)
                        Marshal.ReleaseComObject(this.graphBuilder); this.graphBuilder = null;
                    if (this.dvdGraph != null)
                        Marshal.ReleaseComObject(dvdGraph); dvdGraph = null;

                    GC.Collect();
                }
            }
            catch
            {
            }
        }