diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs index d2a0758..24968bb 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Handlers/Integrations/MPRISIntegration.cs @@ -64,7 +64,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations //Task SetPosition(ObjectPath trackID, long position); Task OpenUriAsync(); - Task WatchSeekedAsync(Action handler, Action onError = null); + //Task WatchSeekedAsync(Action handler, Action onError = null); Task> GetAllAsync(); Task GetAsync(string prop); @@ -75,7 +75,11 @@ namespace FRESHMusicPlayer.Handlers.Integrations #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public class Player : IPlayer { + public event Action OnPropertiesChanged; + private FRESHMusicPlayer.Player player; + private IDictionary properties; + public Player(FRESHMusicPlayer.Player player) { this.player = player; @@ -83,18 +87,9 @@ namespace FRESHMusicPlayer.Handlers.Integrations public ObjectPath ObjectPath => new("/org/mpris/MediaPlayer2"); - public async Task> GetAllAsync() - { - Console.WriteLine("Not implemented: GetAllAsync"); - return new Dictionary(); - } - - public async Task GetAsync(string prop) - { - Console.WriteLine("Not implemented: GetAsync"); - return new object(); - } + public async Task> GetAllAsync() => properties; + public async Task GetAsync(string prop) => properties[prop]; public async Task NextAsync() { @@ -124,7 +119,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations public async Task SetAsync(string prop, object val) { - Console.WriteLine("Not implemented: Set"); + properties[prop] = val; } /* public async Task SetPosition(ObjectPath trackID, long position) @@ -137,18 +132,14 @@ namespace FRESHMusicPlayer.Handlers.Integrations player.StopMusic(); } - public async Task WatchPropertiesAsync(Action handler) - { - Console.WriteLine("Not implemented: WatchProperties"); - return new LiteDB.LiteDatabase("lols.db"); - } + public async Task WatchPropertiesAsync(Action handler) => SignalWatcher.AddAsync(this, nameof(OnPropertiesChanged), handler); - public async Task WatchSeekedAsync(Action handler, Action onError = null) - { - Console.WriteLine("Not implemented: WatchSeekedAsync"); - return new LiteDB.LiteDatabase("lols2.db"); + //public async Task WatchSeekedAsync(Action handler, Action onError = null) + //{ + // Console.WriteLine("Not implemented: WatchSeekedAsync"); + // return new LiteDB.LiteDatabase("lols2.db"); - } + //} } #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously }