Add support for readpicture, aka embedded cover art

This commit is contained in:
Théo Marchal 2022-04-11 12:37:12 +02:00
parent 0ab1afc2f8
commit 4136c13d5b

View File

@ -384,6 +384,7 @@ namespace unison
List<byte> data = new List<byte>();
try
{
bool ReadPictureFailed = true;
long totalBinarySize = 9999;
long currentSize = 0;
@ -392,6 +393,28 @@ namespace unison
if (_connection == null)
return;
IMpdMessage<MpdBinaryData> 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<MpdBinaryData> 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)
{