Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
[MV-153] Fix aspect ratio issues (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
graszka22 authored Oct 12, 2022
1 parent 28f28cf commit 827f740
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,29 @@ class VideoTextureViewRenderer : TextureView, SurfaceHolder.Callback, SurfaceTex
val drawnFrameWidth: Int
val drawnFrameHeight: Int

var width = this.width
var height = this.height

when (scalingType) {
ScalingType.SCALE_ASPECT_FILL ->
ScalingType.SCALE_ASPECT_FILL -> {
if (frameAspectRatio > layoutAspectRatio) {
drawnFrameWidth = (rotatedFrameHeight * layoutAspectRatio).toInt()
drawnFrameHeight = rotatedFrameHeight
} else {
drawnFrameWidth = rotatedFrameWidth
drawnFrameHeight = (rotatedFrameWidth / layoutAspectRatio).toInt()
}
// Aspect ratio of the drawn frame and the view is the same.
width = Math.min(width, drawnFrameWidth)
height = Math.min(height, drawnFrameHeight)
}

else -> {
drawnFrameWidth = rotatedFrameWidth
drawnFrameHeight = rotatedFrameHeight
width = rotatedFrameWidth
height = rotatedFrameHeight
}
}

// Aspect ratio of the drawn frame and the view is the same.
val width = Math.min(width, drawnFrameWidth)
val height = Math.min(height, drawnFrameHeight)

logD(
"updateSurfaceSize() "
+ "layout size: ${getWidth()} x ${getHeight()}, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class RoomActivity : AppCompatActivity() {
ParticipantCard(
participant = it,
videoViewLayout = VideoViewLayout.FIT,
size = Size(150f, 150 * (16f / 9f))
size = Size(200f, 200 * (16f / 9f))
)
}

Expand Down Expand Up @@ -204,15 +204,18 @@ fun ParticipantCard(
) {
onClick?.invoke()
}
.clip(RoundedCornerShape(10.dp))
.height(size.height.dp)
.width(size.width.dp)
.background(Blue.darker(0.7f))
) {
ParticipantVideoView(
participant = participant,
videoViewLayout = videoViewLayout ,
modifier = Modifier
.padding(10.dp)
.clip(RoundedCornerShape(10.dp))
.height(size.height.dp)
.width(size.width.dp)
.align(Alignment.Center)
.fillMaxWidth()
.fillMaxHeight()
.background(Blue.darker(0.7f))
)

Expand Down

0 comments on commit 827f740

Please sign in to comment.