void TestPlayAtTimeInTitle() { int hr; DvdHMSFTimeCode pStartTime = new DvdHMSFTimeCode(); IDvdCmd ppCmd; DvdPlaybackLocation2 pLocation; AllowPlay(); pStartTime.bHours = 0; pStartTime.bMinutes = 0; pStartTime.bSeconds = 1; pStartTime.bFrames = 0; hr = m_idc2.PlayAtTimeInTitle(2, pStartTime, DvdCmdFlags.Flush | DvdCmdFlags.SendEvents, out ppCmd); DsError.ThrowExceptionForHR(hr); hr = m_idi2.GetCurrentLocation(out pLocation); DsError.ThrowExceptionForHR(hr); hr = m_idc2.Stop(); DsError.ThrowExceptionForHR(hr); Debug.Assert(pLocation.TitleNum == 2, "TestPlayAtTimeInTitle"); Debug.Assert(pLocation.TimeCode.bMinutes == 0, "TestPlayAtTimeInTitle2"); Debug.Assert(pLocation.TimeCode.bSeconds == 2, "TestPlayAtTimeInTitle3"); }
/// <summary> /// DVD Code - Play DVD /// </summary> /// <param name="db1"></param> public void PlayDVD(DBTrackInfo db1) { DBLocalMedia mediaToPlay = db1.LocalMedia[0]; if (mediaToPlay.State != MediaState.Online) mediaToPlay.Mount(); while (mediaToPlay.State != MediaState.Online) { Thread.Sleep(1000); }; string dvdNavigator = ""; string dslibdvdnavMonikerString = @"@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{1FFD2F97-0C57-4E21-9FC1-60DF6C6D20BF}"; Log.Info("finding dslibdvdnav filter"); IBaseFilter filter = Marshal.BindToMoniker(dslibdvdnavMonikerString) as IBaseFilter; if (filter != null) { Log.Info("dslibdvdnav filter found!"); DirectShowUtil.ReleaseComObject(filter); filter = null; using (MediaPortal.Profile.Settings xmlreader = mvCentralCore.MediaPortalSettings) { xmlreader.SetValue("dvdplayer", "navigator", "dslibdvdnav"); dvdNavigator = xmlreader.GetValueAsString("dvdplayer", "navigator", "DVD Navigator"); } } else Log.Info("dslibdvdnav filter not found using mp default one!"); MediaPortal.Player.g_Player.Play(mediaToPlay.GetVideoPath()); // reset setting back to original if (dvdNavigator == "dslibdvdnav") using (MediaPortal.Profile.Settings xmlreader = mvCentralCore.MediaPortalSettings) { xmlreader.SetValue("dvdplayer", "navigator", "DVD Navigator"); } PurgeEntries(); l1 = ROTClass.GetFilterGraphsFromROT(); foreach (DSGrapheditROTEntry e1 in l1) { logger.Info(e1.ToString()); _graphBuilder = e1.ConnectToROTEntry() as IGraphBuilder; _dvdbasefilter = DirectShowUtil.GetFilterByName(_graphBuilder, dvdNavigator); _dvdCtrl = _dvdbasefilter as IDvdControl2; _dvdCtrl.SetOption(DvdOptionFlag.HMSFTimeCodeEvents, true); // use new HMSF timecode format _dvdCtrl.SetOption(DvdOptionFlag.ResetOnStop, false); _dvdCtrl.SetDVDDirectory(mediaToPlay.GetVideoPath()); DirectShowUtil.RenderOutputPins(_graphBuilder, _dvdbasefilter); _basicVideo = _graphBuilder as IBasicVideo2; _mediaCtrl = _graphBuilder as IMediaControl; //hr = _mediaCtrl.Run(); //hr = _mediaCtrl.Pause(); //_offsetseek = (ulong)seekbar.Value; TimeSpan t1 = TimeSpan.FromMilliseconds(0); TimeSpan t2 = TimeSpan.Parse(db1.OffsetTime); t1 = t1.Add(t2); // t1 = TimeSpan.Parse(db1.PlayTime); t2 = t2.Add(TimeSpan.Parse(db1.PlayTime)); DvdHMSFTimeCode t3 = mvCentralUtils.ConvertToDvdHMSFTimeCode(t1); DvdHMSFTimeCode t4 = mvCentralUtils.ConvertToDvdHMSFTimeCode(t2); //if (state == FilterState.Stopped) int hr = _mediaCtrl.Run(); hr = _dvdCtrl.PlayAtTimeInTitle(db1.TitleID, t3, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption); // hr = _dvdCtrl.PlayPeriodInTitleAutoStop(6, t3, t4, DvdCmdFlags.Flush | DvdCmdFlags.Block, out _cmdOption); DsError.ThrowExceptionForHR(hr); //int hr = _dvdCtrl.PlayChaptersAutoStop(1, db1.ChapterID, 1, 0, out _cmdOption); //DsError.ThrowExceptionForHR(hr); } }