feat: 添加媒体播放检测功能以优化工作状态管理
This commit is contained in:
@@ -93,10 +93,13 @@ namespace TimerApp
|
||||
}
|
||||
else
|
||||
{
|
||||
// 检测是否有视频/媒体正在播放
|
||||
bool isMediaPlaying = NativeMethods.IsMediaPlaying();
|
||||
|
||||
// 工作/空闲模式逻辑
|
||||
if (idleTime > IdleThreshold)
|
||||
if (idleTime > IdleThreshold || isMediaPlaying)
|
||||
{
|
||||
// 用户离开了
|
||||
// 用户离开了或正在播放视频
|
||||
if (CurrentState == MonitorState.Working)
|
||||
{
|
||||
// 如果正在工作,但离开了,暂停工作计时?
|
||||
@@ -112,10 +115,18 @@ namespace TimerApp
|
||||
{
|
||||
_accumulatedWorkTime = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
// 如果正在播放视频,不累加工作时间,但保持当前状态
|
||||
if (isMediaPlaying && CurrentState == MonitorState.Working)
|
||||
{
|
||||
// 保持当前剩余时间不变(不累加,也不减少)
|
||||
TimeSpan remainingWork = WorkDuration - _accumulatedWorkTime;
|
||||
WorkProgressChanged?.Invoke(this, remainingWork);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 用户在活动
|
||||
// 用户在活动且没有播放视频
|
||||
if (CurrentState == MonitorState.Idle)
|
||||
{
|
||||
// 从空闲变为工作
|
||||
|
||||
Reference in New Issue
Block a user