void CPlayerStatusBar::SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat) { ASSERT(pTimeFormat); ASSERT(rtNow <= rtDur); CString str; CString posstr, durstr, rstr; if (*pTimeFormat == TIME_FORMAT_MEDIA_TIME) { DVD_HMSF_TIMECODE tcNow, tcDur, tcRt; if (fHighPrecision) { tcNow = RT2HMSF(rtNow); tcDur = RT2HMSF(rtDur); tcRt = RT2HMSF(rtDur-rtNow); } else { tcNow = RT2HMS_r(rtNow); tcDur = RT2HMS_r(rtDur); tcRt = RT2HMS_r(rtDur-rtNow); } if (tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0)) { posstr.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds); rstr.Format(_T("%02d:%02d:%02d"), tcRt.bHours, tcRt.bMinutes, tcRt.bSeconds); } else { posstr.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds); rstr.Format(_T("%02d:%02d"), tcRt.bMinutes, tcRt.bSeconds); } if (tcDur.bHours > 0) { durstr.Format(_T("%02d:%02d:%02d"), tcDur.bHours, tcDur.bMinutes, tcDur.bSeconds); } else { durstr.Format(_T("%02d:%02d"), tcDur.bMinutes, tcDur.bSeconds); } if (fHighPrecision) { posstr.AppendFormat(_T(".%03d"), (rtNow/10000)%1000); durstr.AppendFormat(_T(".%03d"), (rtDur/10000)%1000); rstr.AppendFormat(_T(".%03d"), ((rtDur - rtNow)/10000)%1000); } } else if (*pTimeFormat == TIME_FORMAT_FRAME) { posstr.Format(_T("%I64d"), rtNow); durstr.Format(_T("%I64d"), rtDur); rstr.Format(_T("%I64d"), rtDur - rtNow); } if (!AfxGetAppSettings().fRemainingTime) { str = ((rtDur <= 0) || (rtDur < rtNow)) ? posstr : posstr + _T(" / ") + durstr; } else { str = ((rtDur <= 0) || (rtDur < rtNow)) ? posstr : _T("- ") + rstr + _T(" / ") + durstr; } SetStatusTimer(str); }
void CPlayerSeekBar::UpdateToolTipText() { ASSERT(m_bHasDuration); REFERENCE_TIME rtNow = PositionFromClientPoint(m_tooltipPoint); CString time; GUID timeFormat = AfxGetMainFrame()->GetTimeFormat(); if (timeFormat == TIME_FORMAT_MEDIA_TIME) { DVD_HMSF_TIMECODE tcNow = RT2HMS_r(rtNow); if (tcNow.bHours > 0) { time.Format(_T("%02u:%02u:%02u"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds); } else { time.Format(_T("%02u:%02u"), tcNow.bMinutes, tcNow.bSeconds); } } else if (timeFormat == TIME_FORMAT_FRAME) { time.Format(_T("%I64d"), rtNow); } else { ASSERT(FALSE); } CComBSTR chapterName; { CAutoLock lock(&m_csChapterBag); if (m_pChapterBag) { REFERENCE_TIME rt = rtNow; m_pChapterBag->ChapLookup(&rt, &chapterName); } } if (chapterName.Length() == 0) { m_tooltipText = time; } else { m_tooltipText.Format(_T("%s - %s"), time, chapterName); } m_ti.lpszText = (LPTSTR)(LPCTSTR)m_tooltipText; m_tooltip.SetToolInfo(&m_ti); }