コード例 #1
0
ファイル: IDvdCmdTest.cs プロジェクト: ewin66/DirectShow.NET
        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);
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        /// <summary>
        /// Plays a specific title by a given title index
        /// </summary>
        public void PlayTitle(int titleIndex)
        {
            VerifyAccess();

            IDvdCmd cmd;

            m_dvdControl.PlayTitle(titleIndex, DvdCmdFlags.Flush, out cmd);

            if (cmd != null)
            {
                Marshal.ReleaseComObject(cmd);
            }
        }
コード例 #4
0
ファイル: Grabber.cs プロジェクト: RoChess/mvcentral
        private void RunGraph()
        {
            try
            {
                int hr = 0;
                if (mvs.LocalMedia[0].IsDVD)
                {
                    hr = _mediaCtrl.Run();
//                    hr = _dvdCtrl.PlayTitle(1, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption);
//                    hr = _dvdCtrl.ShowMenu(DvdMenuId.Chapter, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption);
//                    hr = _mediaCtrl.Stop();
//                    hr = _mediaCtrl.Stop();
//                    hr = _mediaCtrl.Run();
//                   hr = _mediaCtrl.Pause();
                    _offsetseek = (ulong)seekbar.Value;
                    TimeSpan t1 = TimeSpan.FromMilliseconds(seekbar.Value);
                    TimeSpan t2 = TimeSpan.Parse(mvs.OffsetTime);
                    t1 = t1.Add(t2);
                    t2 = t2.Add(TimeSpan.Parse(mvs.PlayTime));
                    DvdHMSFTimeCode t3 = mvCentralUtils.ConvertToDvdHMSFTimeCode(t1);
                    DvdHMSFTimeCode t4 = mvCentralUtils.ConvertToDvdHMSFTimeCode(t2);
                    //                if (state == FilterState.Stopped)
//                    hr = _dvdCtrl.PlayPeriodInTitleAutoStop(1, t3, t4, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption);


                    hr = _dvdCtrl.PlayTitle(mvs.TitleID, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption);
                    hr = _dvdCtrl.PlayAtTime(t3, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption);


//                    hr = _dvdCtrl.PlayAtTimeInTitle(mvs.TitleID, t3, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption);
                    DsError.ThrowExceptionForHR(hr);
                    //                   hr = _mediaCtrl.Run();
                    label1.Text = t1.ToString();
                    label2.Text = t2.ToString();
                    //               if (state == FilterState.Stopped) hr = _dvdCtrl.PlayChaptersAutoStop(1, mvs.ChapterID, 1, 0, out _cmdOption);
                    DsError.ThrowExceptionForHR(hr);
                    return;
                }

                if (_mediaCtrl != null)
                {
                    hr = _mediaCtrl.Run();
                    DsError.ThrowExceptionForHR(hr);
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error in play : \r\n\r\n", ex);
            }
        }
コード例 #5
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");
        }
コード例 #6
0
ファイル: DvdPlayer.cs プロジェクト: git-thinh/MediaPortal-2
        /// <summary>
        /// Called to handle DVD event window messages.
        /// </summary>
        private void OnDvdEvent()
        {
            if (_mediaEvt == null || _dvdCtrl == null)
            {
                return;
            }

            IntPtr p1, p2;

            try
            {
                int hr;
                do
                {
                    IMediaEventEx eventEx = (IMediaEventEx)_graphBuilder;
                    EventCode     code;
                    hr = eventEx.GetEvent(out code, out p1, out p2, 0);
                    if (hr < 0)
                    {
                        break;
                    }

                    switch (code)
                    {
                    case EventCode.DvdPlaybackStopped:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer DvdPlaybackStopped event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdError:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer DvdError event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.VMRReconnectionFailed:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer VMRReconnectionFailed event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdWarning:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer DVD warning: {0} {1}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdSubPicictureStreamChange:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdSubPicture Changed to: {0} Enabled: {1}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdCurrentHmsfTime:
                        SetCurrentTime(p1);
                        break;

                    case EventCode.DvdChapterStart:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdChaptStart: {0}", p1.ToInt32());
                        lock (SyncObj)
                        {
                            _currChapter = p1.ToInt32();
                            CalculateDuration();
                        }
                        ServiceRegistration.Get <ILogger>().Debug("  _duration: {0}", _currentTime);
                        break;
                    }

                    case EventCode.DvdTitleChange:
                    {
                        OnTitleSelect(p1.ToInt32());
                        break;
                    }

                    case EventCode.DvdCmdStart:
                        ServiceRegistration.Get <ILogger>().Debug("  DvdCmdStart with pending");
                        break;

                    case EventCode.DvdCmdEnd:
                    {
                        OnCmdComplete(p1);
                        break;
                    }

                    case EventCode.DvdStillOn:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdStillOn: {0}", p1.ToInt32());
                        break;
                    }

                    case EventCode.DvdStillOff:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdStillOff: {0}", p1.ToInt32());
                        break;
                    }

                    case EventCode.DvdButtonChange:
                    {
                        _buttonCount   = p1.ToInt32();
                        _focusedButton = p2.ToInt32();
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdButtonChange: buttons: {0}, focused: {1}", _buttonCount, _focusedButton);
                        break;
                    }

                    case EventCode.DvdNoFpPgc:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdNoFpPgc: {0}", p1.ToInt32());
                        hr = _dvdCtrl.PlayTitle(1, DvdCmdFlags.None, out _cmdOption);
                        break;
                    }

                    case EventCode.DvdAudioStreamChange:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdAudioStreamChange: {0}", p1.ToInt32());
                        break;

                    case EventCode.DvdValidUopsChange:
                        _UOPs = (ValidUOPFlag)p1.ToInt32();
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdValidUopsChange: {0}", _UOPs);
                        break;

                    case EventCode.DvdDomainChange:
                    {
                        _currDomain = (DvdDomain)p1;
                        switch (_currDomain)
                        {
                        case DvdDomain.FirstPlay:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=FirstPlay");
                            _handlesInput = false;
                            break;

                        case DvdDomain.Stop:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=Stop");
                            Stop();
                            break;

                        case DvdDomain.VideoManagerMenu:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=VideoManagerMenu (menu)");
                            _handlesInput = true;
                            break;

                        case DvdDomain.VideoTitleSetMenu:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=VideoTitleSetMenu (menu)");
                            _handlesInput = true;
                            break;

                        case DvdDomain.Title:
                            _handlesInput = false;
                            break;

                        default:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Unhandled event DvdDomainChange: {0}", p1.ToInt32());
                            break;
                        }
                        break;
                    }
                    }

                    eventEx.FreeEventParams(code, p1, p2);
                } while (hr == 0);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Exception in OnDvdEvent()", ex);
            }
        }
コード例 #7
0
        protected override void DoStartRendererWithHint(RenderingStartHint startHint)
        {
            DvdRenderingStartHint hint = startHint as DvdRenderingStartHint;

            if (dvdGraphBuilder == null)
            {
                _vdi = new VideoDvdInformation(renderMediaName);

                InitMedia();
                InitAudioAndVideo();

                // Run the graph to play the media file
                int hr = mediaControl.Run();
                DsError.ThrowExceptionForHR(hr);

                // Give enough time for the filter graph to be completely built
                Thread.Sleep(500);

                rotEntry = new DsROTEntry(mediaControl as IFilterGraph);
            }

            if (hint == DvdRenderingStartHint.MainMenu)
            {
                int hr = dvdControl2.ShowMenu(DvdMenuId.Title, DvdCmdFlags.Flush | DvdCmdFlags.Block, _lastCmd);
                DsError.ThrowExceptionForHR(hr);
            }
            else if (hint == DvdRenderingStartHint.Beginning)
            {
                int hr = 0;

                if (ProTONEConfig.DisableDVDMenu)
                {
                    hr = dvdControl2.PlayTitle(1, DvdCmdFlags.Flush | DvdCmdFlags.Block, _lastCmd);
                }
                else
                {
                    //dvdControl.PlayForwards(1f, DvdCmdFlags.Flush | DvdCmdFlags.Block, _lastCmd);
                    hr = dvdControl2.ShowMenu(DvdMenuId.Title, DvdCmdFlags.Flush | DvdCmdFlags.Block, _lastCmd);
                }

                DsError.ThrowExceptionForHR(hr);
            }
            else if (hint.Location.ChapterNum == 0)
            {
                int hr = dvdControl2.PlayTitle(hint.Location.TitleNum, DvdCmdFlags.Flush | DvdCmdFlags.Block, _lastCmd);
                DsError.ThrowExceptionForHR(hr);
            }
            else
            {
                int hr = dvdControl2.PlayChapterInTitle(hint.Location.TitleNum, hint.Location.ChapterNum,
                                                        DvdCmdFlags.Flush | DvdCmdFlags.Block, _lastCmd);
                DsError.ThrowExceptionForHR(hr);
            }

            if (ProTONEConfig.PrefferedSubtitleLang > 0)
            {
                int sid = _vdi.GetSubtitle(ProTONEConfig.PrefferedSubtitleLang);
                if (sid > 0)
                {
                    SetSubtitleStream(sid);
                }
            }
        }