diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml index 07e3bb5..daa7392 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml @@ -76,6 +76,7 @@ + diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml index 0d3fcfa..20426bd 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml @@ -71,7 +71,7 @@ + Text="{x:Bind ViewModel.TotalDuration.TotalHours, Mode=OneWay, Converter={StaticResource DoubleToDecimalConverter}}" /> false, }; } + + if (CurrentIsPlaying) + { + _scrobbleStopwatch.Start(); + } + else + { + _scrobbleStopwatch.Stop(); + } })); } @@ -349,7 +357,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService } } } - _scrobbleStopwatch.Restart(); + _scrobbleStopwatch.Reset(); CurrentSongInfo = new SongInfo { diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/PlayHistoryService/PlayHistoryService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/PlayHistoryService/PlayHistoryService.cs index ed99f36..5771a00 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/PlayHistoryService/PlayHistoryService.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/PlayHistoryService/PlayHistoryService.cs @@ -99,7 +99,7 @@ namespace BetterLyrics.WinUI3.Services.PlayHistoryService var totalMs = await context.PlayHistory .Where(x => x.StartedAt >= start && x.StartedAt <= end) - .SumAsync(x => x.DurationPlayedMs); // 直接在数据库层面求和 + .SumAsync(x => Math.Min(x.DurationPlayedMs, x.TotalDurationMs)); // 防止超过歌曲本身时长 return TimeSpan.FromMilliseconds(totalMs); }