upload
This commit is contained in:
commit
1c7a8cf25f
579 files changed
+83196
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace VibranceHud.Music;
|
||||
|
||||
internal sealed class WindowsSessionSource : INowPlayingSource
|
||||
{
|
||||
private readonly INowPlayingSource _windows;
|
||||
|
||||
private readonly INowPlayingSource _spotify;
|
||||
|
||||
public bool NeedsWorker => true;
|
||||
|
||||
internal WindowsSessionSource(INowPlayingSource? windows = null, INowPlayingSource? spotify = null)
|
||||
{
|
||||
_windows = windows ?? new GsmtcSource();
|
||||
_spotify = spotify ?? new SpotifyWindowTitleSource();
|
||||
}
|
||||
|
||||
public NowPlaying? Read()
|
||||
{
|
||||
return Read(CancellationToken.None);
|
||||
}
|
||||
|
||||
public NowPlaying? Read(CancellationToken cancellation)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _windows.Read(cancellation);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
return _spotify.Read(cancellation);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryCommand(MediaKey key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _windows.TryCommand(key);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user