Commit fad3de5d authored by Florent Pillet's avatar Florent Pillet Committed by Felix Paul Kühne

fix crash if video view doesn't have a size yet

Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 5dc0a3ee
......@@ -48,15 +48,17 @@
CGRect bounds = layer.bounds;
CGRect videoRect = bounds;
CGFloat xRatio = CGRectGetWidth(bounds)/originalVideoSize.width;
CGFloat yRatio = CGRectGetHeight(bounds)/originalVideoSize.height;
CGFloat ratio = fillScreenEntirely ? MAX(xRatio, yRatio) : MIN(xRatio, yRatio);
videoRect.size.width = ratio*originalVideoSize.width;
videoRect.size.height = ratio*originalVideoSize.height;
videoRect.origin.x += (CGRectGetWidth(bounds) - CGRectGetWidth(videoRect))/2.0;
videoRect.origin.y += (CGRectGetHeight(bounds) - CGRectGetHeight(videoRect))/2.0;
if (originalVideoSize.height > 0 && originalVideoSize.width > 0)
{
CGFloat xRatio = CGRectGetWidth(bounds) / originalVideoSize.width;
CGFloat yRatio = CGRectGetHeight(bounds) / originalVideoSize.height;
CGFloat ratio = fillScreenEntirely ? MAX(xRatio, yRatio) : MIN(xRatio, yRatio);
videoRect.size.width = ratio * originalVideoSize.width;
videoRect.size.height = ratio * originalVideoSize.height;
videoRect.origin.x += (CGRectGetWidth(bounds) - CGRectGetWidth(videoRect)) / 2.0;
videoRect.origin.y += (CGRectGetHeight(bounds) - CGRectGetHeight(videoRect)) / 2.0;
}
videolayer.frame = videoRect;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment