Update FMP Avalonia to FMP Core 4

This commit is contained in:
Royce551 2021-12-26 18:20:16 -06:00
parent 4e49b550dd
commit fac0f052cf
4 changed files with 23 additions and 23 deletions

View file

@ -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)

View file

@ -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()

View file

@ -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)
{

View file

@ -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();
}
}