diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
index 602ece8..d593c92 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
@@ -12,7 +12,7 @@
+ Version="1.2.239.0" />
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml
index 93258ad..81f7ea5 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml
@@ -26,8 +26,9 @@
-
+
+
@@ -36,11 +37,31 @@
+ IsIndeterminate="{x:Bind ViewModel.IsLoading, Mode=OneWay}"
+ Visibility="{x:Bind ViewModel.IsLoading, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
+
+
+
+
+
+
+
+
+
@@ -80,7 +101,7 @@
Glyph=}" />
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/GSMTCService/GSMTCService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/GSMTCService/GSMTCService.cs
index 31f41bd..cccfd77 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/GSMTCService/GSMTCService.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/GSMTCService/GSMTCService.cs
@@ -53,8 +53,6 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
private MediaManager.MediaSession? _currentDesiredSession = null;
- private readonly StatsDashboardControlViewModel _statsDashboardControlViewModel;
-
private readonly IAlbumArtSearchService _albumArtSearchService;
private readonly ILyricsSearchService _lyrcsSearchService;
private readonly ITranslationService _translationService;
@@ -71,7 +69,7 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
private readonly DispatcherQueueTimer? _onMediaPropsChangedTimer;
private readonly DispatcherTimer _scrobbleTimer;
- [ObservableProperty] public partial bool IsScrobbled { get; set; } = false;
+ [ObservableProperty][NotifyPropertyChangedRecipients] public partial bool IsScrobbled { get; set; } = false;
[ObservableProperty] public partial TimeSpan ScrobbledDuration { get; set; } = TimeSpan.Zero;
[ObservableProperty] public partial TimeSpan TargetScrobbledDuration { get; set; } = TimeSpan.Zero;
@@ -82,7 +80,6 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
[ObservableProperty] public partial MediaSourceProviderInfo? CurrentMediaSourceProviderInfo { get; set; }
public GSMTCService(
- StatsDashboardControlViewModel statsDashboardControlViewModel,
ISettingsService settingsService,
IAlbumArtSearchService albumArtSearchService,
ILyricsSearchService lyricsSearchService,
@@ -93,8 +90,6 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
ILastFMService lastFMService,
ILogger logger)
{
- _statsDashboardControlViewModel = statsDashboardControlViewModel;
-
_settingsService = settingsService;
_albumArtSearchService = albumArtSearchService;
_lyrcsSearchService = lyricsSearchService;
@@ -138,10 +133,6 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
_ = Task.Run(async () =>
{
await _playHistoryService.AddLogAsync(playHistoryItem);
- _dispatcherQueue.TryEnqueue(() =>
- {
- _statsDashboardControlViewModel.RefreshData();
- });
});
_logger.LogInformation("ScrobbleTimer_Tick: {} scrobbled", CurrentSongInfo.Title);
}
@@ -273,6 +264,11 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
CurrentPosition = timelineProperties.Position;
CurrentSongInfo.DurationMs = timelineProperties.EndTime.TotalMilliseconds;
UpdateTargetScrobbledDuration();
+ if (CurrentPosition.TotalSeconds == 0)
+ {
+ IsScrobbled = false;
+ ScrobbledDuration = TimeSpan.Zero;
+ }
});
}
@@ -315,6 +311,7 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
currentMediaSourceProviderInfo?.PositionOffset = 0;
}
+ string fixedTitle = mediaProperties.Title;
string fixedArtist = mediaProperties.Artist;
string fixedAlbum = mediaProperties.AlbumTitle;
string? songId = null;
@@ -343,7 +340,7 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
.FirstOrDefault(x => x.StartsWith(ExtendedGenreFiled.FileName))?
.Replace(ExtendedGenreFiled.FileName, "");
- CurrentSongInfo.Title = mediaProperties.Title;
+ CurrentSongInfo.Title = fixedTitle;
CurrentSongInfo.Artists = fixedArtist.SplitByCommonSplitter();
CurrentSongInfo.Album = fixedAlbum;
CurrentSongInfo.DurationMs = mediaSession.ControlSession.GetTimelineProperties().EndTime.TotalMilliseconds;
@@ -351,11 +348,9 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
CurrentSongInfo.SongId = songId;
CurrentSongInfo.LinkedFileName = linkedFileName;
- _scrobbleTimer.Stop();
+ UpdateTargetScrobbledDuration();
IsScrobbled = false;
ScrobbledDuration = TimeSpan.Zero;
- UpdateTargetScrobbledDuration();
- _scrobbleTimer.Start();
if (PlayerIdHelper.IsLXMusic(sessionId))
{
@@ -410,22 +405,16 @@ namespace BetterLyrics.WinUI3.Services.GSMTCService
private MediaManager.MediaSession? GetCurrentDesiredSession()
{
var focusedSession = _mediaManager.GetFocusedSession();
- if (focusedSession == null)
- {
- return null;
- }
- if (IsMediaSourceEnabled(focusedSession.Id))
+ if (focusedSession != null && IsMediaSourceEnabled(focusedSession.Id))
{
return focusedSession;
}
- else
+
+ foreach (var session in _mediaManager.CurrentMediaSessions.Values)
{
- foreach (var session in _mediaManager.CurrentMediaSessions.Values)
+ if (IsMediaSourceEnabled(session.Id))
{
- if (IsMediaSourceEnabled(session.Id))
- {
- return session;
- }
+ return session;
}
}
return null;
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ar/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ar/Resources.resw
index 496e4d1..46fc507 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ar/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ar/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
الأكثر نشاطاً
+
+
+
المصادر
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/de/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/de/Resources.resw
index 91451b9..f3048bc 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/de/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/de/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Aktivste
+
+
+
Quellen
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en/Resources.resw
index 6aba6f5..a96ea27 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en/Resources.resw
@@ -1482,6 +1482,9 @@
Most Active
+
+ Scrobbling...
+
Sources
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/es/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/es/Resources.resw
index 71065a2..c586ed8 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/es/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/es/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Más activos
+
+
+
Fuentes
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/fr/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/fr/Resources.resw
index 82e2b2f..e239613 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/fr/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/fr/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Les plus actifs
+
+
+
Sources d'information
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/hi/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/hi/Resources.resw
index 4486268..f174d54 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/hi/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/hi/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
सर्वाधिक सक्रिय
+
+
+
स्रोत
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/id/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/id/Resources.resw
index 5de03c0..348b6bf 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/id/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/id/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Paling Aktif
+
+
+
Sumber
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja/Resources.resw
index 2f781b1..f684bf5 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
最多アクティブ
+
+
+
再生ソース
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko/Resources.resw
index 3f8db69..c7983fc 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
가장 활동적인
+
+
+
출처
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ms/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ms/Resources.resw
index 35acb7e..00db82c 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ms/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ms/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Paling Aktif
+
+
+
Sumber
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/pt/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/pt/Resources.resw
index 738d3c1..eea310e 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/pt/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/pt/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Mais activos
+
+
+
Fontes
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ru/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ru/Resources.resw
index 987e0cc..b261fbf 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ru/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ru/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Самые активные
+
+
+
Источники
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/th/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/th/Resources.resw
index a85b5f0..286f8cd 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/th/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/th/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
กิจกรรมล่าสุด
+
+
+
แหล่งข้อมูล
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/vi/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/vi/Resources.resw
index e5ef09b..56c5697 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/vi/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/vi/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
Hoạt động nhiều nhất
+
+
+
Nguồn
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hans/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hans/Resources.resw
index e3df33e..55e3c4a 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hans/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hans/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
最活跃时段
+
+ 记录中...
+
播放源
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hant/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hant/Resources.resw
index b6380f9..836ab6f 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hant/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-Hant/Resources.resw
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1482,6 +1482,9 @@
最活躍
+
+
+
來源
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/StatsDashboardControlViewModel.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/StatsDashboardControlViewModel.cs
index 264f01a..a4c390f 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/StatsDashboardControlViewModel.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/StatsDashboardControlViewModel.cs
@@ -3,10 +3,13 @@ using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Stats;
using BetterLyrics.WinUI3.Services.AlbumArtSearchService;
+using BetterLyrics.WinUI3.Services.GSMTCService;
using BetterLyrics.WinUI3.Services.LocalizationService;
using BetterLyrics.WinUI3.Services.PlayHistoryService;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using CommunityToolkit.Mvvm.Messaging;
+using CommunityToolkit.Mvvm.Messaging.Messages;
using CommunityToolkit.WinUI;
using LiveChartsCore;
using LiveChartsCore.Kernel;
@@ -27,7 +30,7 @@ using System.Xml.Linq;
namespace BetterLyrics.WinUI3.ViewModels
{
- public partial class StatsDashboardControlViewModel : BaseViewModel
+ public partial class StatsDashboardControlViewModel : BaseViewModel, IRecipient>
{
private readonly IPlayHistoryService _playHistoryService;
private readonly ILocalizationService _localizationService;
@@ -37,6 +40,8 @@ namespace BetterLyrics.WinUI3.ViewModels
private readonly DispatcherQueueTimer _timer;
+ [ObservableProperty] public partial IGSMTCService GSMTCService { get; set; }
+
[ObservableProperty] public partial bool IsLoading { get; set; } = false;
// 时间筛选
@@ -67,11 +72,16 @@ namespace BetterLyrics.WinUI3.ViewModels
// 歌曲
[ObservableProperty] public partial ObservableCollection TopSongs { get; set; } = new();
- public StatsDashboardControlViewModel(IPlayHistoryService playHistoryService, ILocalizationService localizationService, IAlbumArtSearchService albumArtSearchService)
+ public StatsDashboardControlViewModel(
+ IPlayHistoryService playHistoryService,
+ ILocalizationService localizationService,
+ IAlbumArtSearchService albumArtSearchService,
+ IGSMTCService gsmtcService)
{
_playHistoryService = playHistoryService;
_localizationService = localizationService;
_albumArtSearchService = albumArtSearchService;
+ GSMTCService = gsmtcService;
_localizedTimesValue = _localizationService.GetLocalizedString("StatsDashboardControlTimes");
@@ -194,7 +204,7 @@ namespace BetterLyrics.WinUI3.ViewModels
}
[RelayCommand]
- public void RefreshData()
+ private void RefreshData()
{
if (IsCustomRangeSelected)
{
@@ -264,5 +274,18 @@ namespace BetterLyrics.WinUI3.ViewModels
LoadData(); // 生成完刷新
}
+ public void Receive(PropertyChangedMessage message)
+ {
+ if (message.Sender is IGSMTCService)
+ {
+ if (message.PropertyName == nameof(IGSMTCService.IsScrobbled))
+ {
+ if (message.NewValue == true)
+ {
+ RefreshData();
+ }
+ }
+ }
+ }
}
}
\ No newline at end of file