diff --git a/Handlers/MPDHandler.cs b/Handlers/MPDHandler.cs index b6c1064..0b65010 100644 --- a/Handlers/MPDHandler.cs +++ b/Handlers/MPDHandler.cs @@ -384,6 +384,7 @@ namespace unison List data = new List(); try { + bool ReadPictureFailed = true; long totalBinarySize = 9999; long currentSize = 0; @@ -392,6 +393,28 @@ namespace unison if (_connection == null) return; + IMpdMessage albumReq = await _connection.SendAsync(new ReadPictureCommand(path, currentSize)); + if (!albumReq.IsResponseValid) + break; + + MpdBinaryData response = albumReq.Response.Content; + if (response == null || response.Binary == 0) + break; + + ReadPictureFailed = false; + totalBinarySize = response.Size; + currentSize += response.Binary; + data.AddRange(response.Data); + } + while (currentSize < totalBinarySize && !token.IsCancellationRequested); + + do + { + if (!ReadPictureFailed) + break; + if (_connection == null) + return; + IMpdMessage albumReq = await _connection.SendAsync(new AlbumArtCommand(path, currentSize)); if (!albumReq.IsResponseValid) break; @@ -403,7 +426,8 @@ namespace unison totalBinarySize = response.Size; currentSize += response.Binary; data.AddRange(response.Data); - } while (currentSize < totalBinarySize && !token.IsCancellationRequested); + } + while (currentSize < totalBinarySize && !token.IsCancellationRequested); } catch (Exception e) {