function GetRect(Panel: TPanel): TRect;
var Width, Height: Integer; newWidth, newHeight: Single; T: Integer;
begin
Result := Panel.ClientRect;
if not GetSizeInfo(frmDetails.MediaPlayer.FileName, Width, Height)
then exit;
newWidth := (Width * (Result.Bottom - Result.Top)) / Height;
newHeight := (Height * (Result.Right - Result.Left)) / Width;
if (newWidth < (Result.Right - Result.Left))
and
(newHeight > (Result.Bottom - Result.Top))
then
begin
T := Round((Result.Right - Result.Left - newWidth) / 2);
Inc(Result.Left, T);
Dec(Result.Right, 2*T);
end
else if (newHeight < (Result.Bottom - Result.Top))
and
(newWidth > (Result.Right - Result.Left))
then
begin
T := Round((Result.Bottom - Result.Top - newHeight) / 2);
Inc(Result.Top, T);
Dec(Result.Bottom, 2*T);
end
end;