mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
fix: thread access issue related to ISettingsService
This commit is contained in:
@@ -37,7 +37,6 @@ namespace BetterLyrics.WinUI3
|
||||
{
|
||||
|
||||
private readonly ILogger<App> _logger;
|
||||
private readonly ISettingsService _settingsService;
|
||||
|
||||
public static new App Current => (App)Application.Current;
|
||||
|
||||
@@ -54,7 +53,6 @@ namespace BetterLyrics.WinUI3
|
||||
ConfigureServices();
|
||||
|
||||
_logger = Ioc.Default.GetRequiredService<ILogger<App>>();
|
||||
_settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
|
||||
|
||||
UnhandledException += App_UnhandledException;
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
@@ -76,7 +74,7 @@ namespace BetterLyrics.WinUI3
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
WindowHelper.OpenOrShowWindow<LyricsWindow>();
|
||||
if (_settingsService.AppSettings.MusicGallerySettings.AutoOpen)
|
||||
if (Ioc.Default.GetRequiredService<ISettingsService>().AppSettings.MusicGallerySettings.AutoOpen)
|
||||
{
|
||||
WindowHelper.OpenOrShowWindow<MusicGalleryWindow>();
|
||||
}
|
||||
|
||||
@@ -115,10 +115,12 @@ namespace BetterLyrics.WinUI3.ViewModels
|
||||
|
||||
_mediaPlayer.MediaOpened += MediaPlayer_MediaOpened;
|
||||
_mediaPlayer.MediaEnded += MediaPlayer_MediaEnded;
|
||||
_mediaPlayer.CommandManager.IsEnabled = false;
|
||||
|
||||
_timelineController = _mediaPlayer.TimelineController = new();
|
||||
_timelineController.PositionChanged += TimelineController_PositionChanged;
|
||||
|
||||
_smtc = _mediaPlayer.SystemMediaTransportControls;
|
||||
_mediaPlayer.CommandManager.IsEnabled = false;
|
||||
_smtc.IsPlayEnabled = true;
|
||||
_smtc.IsPauseEnabled = true;
|
||||
_smtc.IsNextEnabled = true;
|
||||
|
||||
Reference in New Issue
Block a user