feat(VideoContainer) add option to avoid cropping focused video

This commit is contained in:
adam j hartz 2021-08-26 05:23:19 -04:00 committed by GitHub
parent cf6d6f8a12
commit 70b369a1af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -224,7 +224,8 @@ var interfaceConfig = {
// Determines how the video would fit the screen. 'both' would fit the whole // Determines how the video would fit the screen. 'both' would fit the whole
// screen, 'height' would fit the original video height to the height of the // screen, 'height' would fit the original video height to the height of the
// screen, 'width' would fit the original video width to the width of the // screen, 'width' would fit the original video width to the width of the
// screen respecting ratio. // screen respecting ratio, 'nocrop' would make the video as large as
// possible and preserve aspect ratio without cropping.
VIDEO_LAYOUT_FIT: 'both', VIDEO_LAYOUT_FIT: 'both',
/** /**

View File

@ -98,14 +98,21 @@ function computeCameraVideoSize( // eslint-disable-line max-params
} }
const aspectRatio = videoWidth / videoHeight; const aspectRatio = videoWidth / videoHeight;
const videoSpaceRatio = videoSpaceWidth / videoSpaceHeight;
switch (videoLayoutFit) { switch (videoLayoutFit) {
case 'height': case 'height':
return [ videoSpaceHeight * aspectRatio, videoSpaceHeight ]; return [ videoSpaceHeight * aspectRatio, videoSpaceHeight ];
case 'width': case 'width':
return [ videoSpaceWidth, videoSpaceWidth / aspectRatio ]; return [ videoSpaceWidth, videoSpaceWidth / aspectRatio ];
case 'nocrop':
return computeCameraVideoSize(
videoWidth,
videoHeight,
videoSpaceWidth,
videoSpaceHeight,
videoSpaceRatio < aspectRatio ? 'width' : 'height');
case 'both': { case 'both': {
const videoSpaceRatio = videoSpaceWidth / videoSpaceHeight;
const maxZoomCoefficient = interfaceConfig.MAXIMUM_ZOOMING_COEFFICIENT const maxZoomCoefficient = interfaceConfig.MAXIMUM_ZOOMING_COEFFICIENT
|| Infinity; || Infinity;