我面临着这个奇怪的问题,SurfaceViewRenderer每当我在横向/反向横向/传感器横向中运行活动时,预览就会变成空白。奇怪的问题是,在某些手机中,视频预览以反向横向模式工作,而在某些手机中以横向模式工作。例如,当我在 中运行 Activity 时Android 5.0,横向模式下的视频预览工作正常,但在反向横向模式下则不行。然后我尝试在我正在运行的一加手机上执行相同的操作Android 10。这里 SurfaceViewRenderer 中的视频预览在反向横向模式下工作正常,但在横向模式下则不然。
注意:即使预览变为空白,远程流也可以正常工作,没有任何问题,只有视频预览不起作用。它以某种方式无法更新,SurfaceViewRenderer但没有问题流向远程参与者。
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.session.activities.LiveSessionActivity">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/localGLSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
<View
android:id="@+id/vBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.4"
android:background="@android:color/black"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/localGLSurfaceView"
app:layout_constraintEnd_toEndOf="@+id/localGLSurfaceView"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/localGLSurfaceView"
app:layout_constraintTop_toTopOf="@+id/localGLSurfaceView"
app:layout_constraintVertical_bias="0.0" />
<View
android:id="@+id/vShadow"
android:layout_width="wrap_content"
android:layout_height="@dimen/_42sdp"
android:background="@drawable/ic_rectangle_shadow"
app:layout_constraintEnd_toEndOf="@+id/localGLSurfaceView"
app:layout_constraintStart_toStartOf="@+id/localGLSurfaceView"
app:layout_constraintTop_toTopOf="@+id/localGLSurfaceView" />
<ImageView
android:id="@+id/ivBackButton"
android:layout_width="@dimen/_8sdp"
android:layout_height="@dimen/_13sdp"
android:layout_marginStart="@dimen/_12sdp"
android:layout_marginTop="@dimen/_16sdp"
android:src="@drawable/ic_back"
app:layout_constraintStart_toStartOf="@+id/localGLSurfaceView"
app:layout_constraintTop_toTopOf="@+id/localGLSurfaceView" />
<TextView
android:id="@+id/tvLiveClassName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_12sdp"
android:text="Live Class 10"
android:textColor="@android:color/white"
android:textSize="@dimen/medium_text"
app:layout_constraintBottom_toBottomOf="@+id/ivBackButton"
app:layout_constraintStart_toEndOf="@+id/ivBackButton"
app:layout_constraintTop_toTopOf="@+id/ivBackButton" />
<TextView
android:id="@+id/tvCountDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:textColor="@android:color/white" …Run Code Online (Sandbox Code Playgroud)