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 CPlayerToolBar::SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat, double playRate) { ASSERT(pTimeFormat); CString str; CString posstr, durstr; if(*pTimeFormat == TIME_FORMAT_MEDIA_TIME) { DVD_HMSF_TIMECODE tcNow = RT2HMSF(rtNow); DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur); if(tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0)) posstr.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds); else posstr.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.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) { str.Format(_T("%s.%03d"), posstr, (rtNow/10000)%1000); posstr = str; str.Format(_T("%s.%03d"), durstr, (rtDur/10000)%1000); durstr = str; str.Empty(); } } else if(*pTimeFormat == TIME_FORMAT_FRAME) { posstr.Format(_T("%I64d"), rtNow); durstr.Format(_T("%I64d"), rtDur); } str = (/*start <= 0 &&*/ rtDur <= 0) ? posstr : posstr + _T(" / ") + durstr; SYSTEM_POWER_STATUS status; GetSystemPowerStatus(&status); CString szPower ; if ( status.BatteryFlag != 128 && status.BatteryFlag != 255 && status.BatteryLifePercent < 91 ){ szPower.Format(ResStr(IDS_STATUS_BAR_LABEL_BATTRAY_WITH_PADDING), status.BatteryLifePercent); }else{ //szPower = ResStr(IDS_STATUS_BAR_LABEL_BATTRAY_UNLIMIT); } CString szPlayrate; if(fabs(playRate - 1.0) > 0.02 && playRate > 0.01) { szPlayrate.Format(ResStr(IDS_STATUS_BAR_LABEL_PLAY_SPEED_WITH_PADDING), playRate); } CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd()); CString szPlayingFileName = pFrame->GetCurPlayingFileName(); if(!szPlayingFileName.IsEmpty()){ //szPlayingFileName.Append(_T(" ")); } //szPlayingFileName SetStatusTimer( str + szPlayrate + szPower + m_buffering ); }