From fac0f052cf6320ddfb78c88352e70c7134a85713 Mon Sep 17 00:00:00 2001 From: Royce551 Date: Sun, 26 Dec 2021 18:20:16 -0600 Subject: [PATCH] Update FMP Avalonia to FMP Core 4 --- .../Handlers/Integrations/MPRISIntegration.cs | 2 +- .../ViewModels/MainWindowViewModel.cs | 34 +++++++++---------- .../ViewModels/QueueManagementViewModel.cs | 4 +-- .../Views/MainWindow.axaml.cs | 6 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs index 3f82104..7ac94c6 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs @@ -241,7 +241,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations public async Task StopAsync() { - viewModel.Player.StopMusic(); + viewModel.Player.Stop(); } public async Task SetPositionAsync(ObjectPath trackID, long position) diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs index 5416d4e..70ef0c9 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs @@ -156,10 +156,10 @@ namespace FRESHMusicPlayer.ViewModels set => Player.Queue.Shuffle = value; } - public void SkipPreviousCommand() + public async void SkipPreviousCommand() { if (!Player.FileLoaded) return; - if (Player.CurrentTime.TotalSeconds <= 5) Player.PreviousSong(); + if (Player.CurrentTime.TotalSeconds <= 5) await Player.PreviousAsync(); else { Player.CurrentTime = TimeSpan.FromSeconds(0); @@ -188,12 +188,12 @@ namespace FRESHMusicPlayer.ViewModels { if (Player.Paused) { - Player.ResumeMusic(); + Player.Resume(); Integrations.Update(CurrentTrack, PlaybackStatus.Playing); } else { - Player.PauseMusic(); + Player.Pause(); Integrations.Update(CurrentTrack, PlaybackStatus.Paused); } UpdatePausedState(); @@ -212,9 +212,9 @@ namespace FRESHMusicPlayer.ViewModels } this.RaisePropertyChanged(nameof(Shuffle)); } - public void SkipNextCommand() + public async void SkipNextCommand() { - Player.NextSong(); + await Player.NextAsync(); } public void PauseAfterCurrentTrackCommand() => PauseAfterCurrentTrack = !PauseAfterCurrentTrack; @@ -375,14 +375,14 @@ namespace FRESHMusicPlayer.ViewModels if (args.Count != 0) { Player.Queue.Add(args.ToArray()); - Player.PlayMusic(); + await Player.PlayAsync(); } else { if (!string.IsNullOrEmpty(Program.Config.FilePath)) { PauseAfterCurrentTrack = true; - Player.PlayMusic(Program.Config.FilePath); + await Player.PlayAsync(Program.Config.FilePath); Player.CurrentTime.Add(TimeSpan.FromSeconds(Program.Config.FilePosition)); } } @@ -563,11 +563,11 @@ namespace FRESHMusicPlayer.ViewModels UpdateLibraryInfo(); } - public void PlayCommand(string path) + public async void PlayCommand(string path) { Player.Queue.Clear(); Player.Queue.Add(path); - Player.PlayMusic(); + await Player.PlayAsync(); } public void EnqueueCommand(string path) { @@ -582,11 +582,11 @@ namespace FRESHMusicPlayer.ViewModels { Player.Queue.Add(AllTracks.Select(x => x.Path).ToArray()); } - public void PlayAllCommand() + public async void PlayAllCommand() { Player.Queue.Clear(); Player.Queue.Add(AllTracks.Select(x => x.Path).ToArray()); - Player.PlayMusic(); + await Player.PlayAsync(); } // Searching @@ -750,7 +750,7 @@ namespace FRESHMusicPlayer.ViewModels Player.Queue.Add(reader.FilePaths.ToArray()); await Task.Run(() => Library.Import(reader.FilePaths.ToArray())); - Player.PlayMusic(); + await Player.PlayAsync(); } public async void BrowseFoldersCommand() { @@ -797,7 +797,7 @@ namespace FRESHMusicPlayer.ViewModels || name.EndsWith(".aac")).ToArray(); Player.Queue.Add(paths); await Task.Run(() => Library.Import(paths)); - Player.PlayMusic(); + await Player.PlayAsync(); } } public async void OpenTrackCommand() @@ -823,15 +823,15 @@ namespace FRESHMusicPlayer.ViewModels if (files.Length > 0) { Player.Queue.Add(files); - Player.PlayMusic(); + await Player.PlayAsync(); } } - public void ImportFilePathCommand() + public async void ImportFilePathCommand() { if (string.IsNullOrEmpty(FilePathOrURL)) return; Player.Queue.Add(FilePathOrURL); Library.Import(FilePathOrURL); - Player.PlayMusic(); + await Player.PlayAsync(); } public async void GoToArtistCommand() diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/QueueManagementViewModel.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/QueueManagementViewModel.cs index f020716..f9e5e9d 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/QueueManagementViewModel.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/QueueManagementViewModel.cs @@ -52,10 +52,10 @@ namespace FRESHMusicPlayer.ViewModels } } - public void JumpToCommand(int position) + public async void JumpToCommand(int position) { Player.Queue.Position = position - 1; - Player.PlayMusic(); + await Player.PlayAsync(); } public void RemoveCommand(int position) { diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs index ee6d4bb..b5d8d7a 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs @@ -166,7 +166,7 @@ namespace FRESHMusicPlayer.Views case Key.OemTilde: var dialog = new TextEntryBox().SetStuff(Properties.Resources.FilePathOrUrl); await dialog.ShowDialog(this); - if (dialog.OK) ViewModel.Player.PlayMusic((dialog.DataContext as TextEntryBoxViewModel).Text); + if (dialog.OK) await ViewModel.Player.PlayAsync((dialog.DataContext as TextEntryBoxViewModel).Text); break; case Key.F1: InterfaceUtils.OpenURL("https://royce551.github.io/FRESHMusicPlayer/docs/index.html"); @@ -199,10 +199,10 @@ namespace FRESHMusicPlayer.Views { e.DragEffects &= DragDropEffects.Copy; } - private void OnDragDrop(object sender, DragEventArgs e) + private async void OnDragDrop(object sender, DragEventArgs e) { ViewModel.Player.Queue.Add(e.Data.GetFileNames().ToArray()); - ViewModel.Player.PlayMusic(); + await ViewModel.Player.PlayAsync(); } }