Esempio n. 1
0
        /// <summary>
        /// Restores the DVD playback state from a formerly saved resume state.
        /// </summary>
        /// <param name="resumeData">The resume data which was retrieved by calling <see cref="GetResumeState"/>.</param>
        private void SetResumeState(byte[] resumeData)
        {
            if ((resumeData != null) && (resumeData.Length > 0))
            {
                IDvdState dvdState;

                int hr = _dvdInfo.GetState(out dvdState);
                if (hr < 0)
                {
                    return;
                }
                IPersistMemory dvdStatePersistMemory = (IPersistMemory)dvdState;
                IntPtr         stateData             = Marshal.AllocHGlobal(resumeData.Length);
                Marshal.Copy(resumeData, 0, stateData, resumeData.Length);

                try
                {
                    dvdStatePersistMemory.Load(stateData, (uint)resumeData.Length);
                }
                finally
                {
                    Marshal.FreeHGlobal(stateData);
                }

                hr = _dvdCtrl.SetState(dvdState, DvdCmdFlags.Block, out _cmdOption);
                if (hr == 0)
                {
                    return;
                }

                Marshal.ReleaseComObject(dvdState);
            }
            return;
        }
Esempio n. 2
0
        void TestState()
        {
            int       hr;
            IDvdCmd   ppCmd;
            IDvdState dss;

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

            Thread.Sleep(500);

            hr = m_idi2.GetState(out dss);
            DsError.ThrowExceptionForHR(hr);

            Thread.Sleep(3000);

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

            Thread.Sleep(500);

            // Returns a State corrupted error.  C++ returns the same thing.
            hr = m_idc2.SetState(dss, DvdCmdFlags.Block, out ppCmd);
            //DsError.ThrowExceptionForHR(hr);
        }