using CommunityToolkit.Mvvm.Input; namespace Hyperbar.Widget.MediaController.Windows; public class MediaControllerPlaybackStatusHandler(IMediator mediator, IServiceFactory factory) : INotificationHandler> { public async Task Handle(Changed notification, CancellationToken cancellationToken) { if (notification.Value is MediaControllerPlaybackStatus mediaControllerPlaybackInformation) { if (mediaControllerPlaybackInformation.Status is PlaybackStatus.Playing) { await mediator.PublishAsync(new Replaced(2, factory.Create( PlaybackButtonType.Pause, "Pause", "\uE769", new RelayCommand(async () => await mediator.PublishAsync()))), nameof(MediaControllerViewModel), cancellationToken); } if (mediaControllerPlaybackInformation.Status is PlaybackStatus.Paused) { await mediator.PublishAsync(new Replaced(2, factory.Create( PlaybackButtonType.Pause, "Play", "\uE768", new RelayCommand(async () => await mediator.PublishAsync()))), nameof(MediaControllerViewModel), cancellationToken); } } } }