Cover images working in all cases

This commit is contained in:
Théo Marchal 2022-11-05 01:05:46 +01:00
parent b33ae3b9be
commit 0471ba88c1

View File

@ -46,7 +46,7 @@ namespace unison
private MpdStatus _currentStatus; private MpdStatus _currentStatus;
private IMpdFile _currentSong; private IMpdFile _currentSong;
private BitmapFrame _cover; private BitmapImage _cover;
public Statistics _stats; public Statistics _stats;
private readonly System.Timers.Timer _elapsedTimer; private readonly System.Timers.Timer _elapsedTimer;
private DispatcherTimer _retryTimer; private DispatcherTimer _retryTimer;
@ -474,14 +474,12 @@ namespace unison
else else
{ {
using MemoryStream stream = new MemoryStream(data.ToArray()); using MemoryStream stream = new MemoryStream(data.ToArray());
try _cover = new BitmapImage();
{ _cover.BeginInit();
_cover = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); _cover.CacheOption = BitmapCacheOption.OnLoad;
} _cover.StreamSource = stream;
catch _cover.EndInit();
{ _cover.Freeze();
_cover = null;
}
} }
UpdateCover(); UpdateCover();
} }
@ -523,7 +521,7 @@ namespace unison
public IMpdFile GetCurrentSong() => _currentSong; public IMpdFile GetCurrentSong() => _currentSong;
public MpdStatus GetStatus() => _currentStatus; public MpdStatus GetStatus() => _currentStatus;
public BitmapFrame GetCover() => _cover; public BitmapImage GetCover() => _cover;
public string GetVersion() => _version; public string GetVersion() => _version;
public Statistics GetStats() => _stats; public Statistics GetStats() => _stats;
public double GetCurrentTime() => _currentTime; public double GetCurrentTime() => _currentTime;