protected override void OnBeforeGraphRunning() { base.OnBeforeGraphRunning(); // first all automatically rendered pins FilterGraphTools.RenderOutputPins(_graphBuilder, _dvdbasefilter); // MSDN: "During the connection process, the Filter Graph Manager ignores pins on intermediate filters if the pin name begins with a tilde (~)." // then connect the skipped "~" output pins FilterGraphTools.RenderAllManualConnectPins(_graphBuilder); _currTime = new DvdHMSFTimeCode(); }
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); } }
void PlayTitle(DVDTitle title) { if (m_dvdCtrl == null) { PreviewInit(); } IDvdCmd cmd; DvdHMSFTimeCode time = new DvdHMSFTimeCode() { bSeconds = 10 }; m_dvdCtrl.PlayAtTimeInTitle(title.TitleNumber, time, DvdCmdFlags.SendEvents, out cmd); }
/// <summary> /// Converts a <see cref="TimeSpan"/> into a <see cref="DvdHMSFTimeCode"/>. /// </summary> /// <param name="newTime">TimeSpan to convert.</param> /// <returns><see cref="DvdHMSFTimeCode"/> instance.</returns> private static DvdHMSFTimeCode ToTimeCode(TimeSpan newTime) { int hours = newTime.Hours; int minutes = newTime.Minutes; int seconds = newTime.Seconds; DvdHMSFTimeCode timeCode = new DvdHMSFTimeCode { bHours = (byte)(hours & 0xff), bMinutes = (byte)(minutes & 0xff), bSeconds = (byte)(seconds & 0xff), bFrames = 0 }; return(timeCode); }
protected override void SetMediaPosition(double pos) { TimeSpan tsNewPos = TimeSpan.FromSeconds(pos); DvdHMSFTimeCode timeCode = new DvdHMSFTimeCode(); timeCode.bHours = (byte)tsNewPos.TotalHours; timeCode.bMinutes = (byte)tsNewPos.Minutes; timeCode.bSeconds = (byte)tsNewPos.Seconds; timeCode.bFrames = 1; int hr = dvdControl2.PlayAtTime(ref timeCode, DvdCmdFlags.None, _lastCmd); DsError.ThrowExceptionForHR(hr); }
/// <summary> /// Here we extract out the new Dvd duration of /// the title currently being played /// </summary> private void SetTitleDuration() { var totalTime = new DvdHMSFTimeCode(); DvdTimeCodeFlags flags; int hr = m_dvdInfo.GetTotalTitleTime(totalTime, out flags); if (hr != 0) { return; } /* Convert the total time of the title to milliseconds */ Duration = (long)new TimeSpan(totalTime.bHours, totalTime.bMinutes, totalTime.bSeconds).TotalMilliseconds *MEDIA_TIME_TO_MILLISECONDS; }
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"); }