Skip to content

Commit

Permalink
Fix video ratio in VR mode (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
vertexodessa authored Dec 17, 2024
1 parent 84048f5 commit f5f0730
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions app/src/main/java/com/openipc/pixelpilot/VideoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ protected void onCreate(Bundle savedInstanceState) {
constraintSet.setMargin(R.id.surfaceViewLeft, ConstraintSet.END, size);
constraintSet.setMargin(R.id.surfaceViewRight, ConstraintSet.START, size);

//constraintSet.constrainWidth(R.id.surfaceViewLeft, size);
//constraintSet.constrainWidth(R.id.surfaceViewRight, size);
constraintSet.applyTo(constraintLayout);

// Hide SeekBar after 3 seconds
Expand All @@ -288,6 +286,8 @@ protected void onCreate(Bundle savedInstanceState) {
public void run() {
seekBar.setVisibility(View.GONE);
distanceSeekBar.setVisibility(View.GONE);
updateViewRatio(R.id.surfaceViewLeft, lastVideoW, lastVideoH);
updateViewRatio(R.id.surfaceViewRight, lastVideoW, lastVideoH);
}
}, 3000);

Expand All @@ -304,6 +304,8 @@ public boolean onTouch(View v, MotionEvent event) {
public void run() {
seekBar.setVisibility(View.GONE);
distanceSeekBar.setVisibility(View.GONE);
updateViewRatio(R.id.surfaceViewLeft, lastVideoW, lastVideoH);
updateViewRatio(R.id.surfaceViewRight, lastVideoW, lastVideoH);
}
}, 3000);
}
Expand Down Expand Up @@ -845,6 +847,10 @@ public void onVideoRatioChanged(final int videoW, final int videoH) {
}

private void updateViewRatio(int viewId, int videoW, int videoH) {
if (videoW == 0 || videoH == 0) {
return;
}

View view = findViewById(viewId);
if (view != null) {
ConstraintLayout.LayoutParams params =
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_video.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:id="@+id/surfaceViewLeft"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="16:9"
app:layout_constraintDimensionRatio="4:3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -29,7 +29,7 @@
android:id="@+id/surfaceViewRight"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="16:9"
app:layout_constraintDimensionRatio="4:3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/surfaceViewLeft"
Expand Down

0 comments on commit f5f0730

Please sign in to comment.