Added playlist view.

This commit is contained in:
2025-03-27 01:37:32 -04:00
parent 97f6040122
commit b7ba8341a1
13 changed files with 302 additions and 49 deletions

View File

@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.Input;
using Harmonia.Core.Engine;
using Harmonia.Core.Models;
using Harmonia.Core.Player;
using Harmonia.WinUI.Caching;
@@ -7,6 +8,7 @@ using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media.Imaging;
using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
@@ -196,6 +198,7 @@ public partial class PlayerViewModel : ViewModelBase
{
_audioPlayer = audioPlayer;
_audioPlayer.PlayingSongChanged += OnPlayingSongChanged;
_audioPlayer.PropertyChanged += OnAudioPlayerPropertyChanged;
_audioBitmapImageCache = audioBitmapCache;
@@ -232,6 +235,28 @@ public partial class PlayerViewModel : ViewModelBase
DispatcherQueue.GetForCurrentThread().TryEnqueue(() => SongImageSource = bitmapImage);
}
private void OnAudioPlayerPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(_audioPlayer.State):
UpdateTimer();
break;
}
}
private void UpdateTimer()
{
if (_audioPlayer.State == AudioPlaybackState.Playing)
{
_timer.Start();
}
else
{
_timer.Stop();
}
}
private void TickTock(object? sender, object e)
{
Position = _audioPlayer.Position;