【发布时间】:2023-03-03 12:51:01
【问题描述】:
在我的应用程序中,我将 openTok 用于音频和视频通话功能。附件是我为视频通话创建的图像,用于旋转相机视图,有一个相机旋转图标。
在发布流之前,这个旋转相机的图标就位,但是一旦发布流,这个图标就会消失。之所以会这样,是因为 z 顺序。发布流的代码如下:
private void startPublisherStreaming() {
mPublisher = new Publisher.Builder(getContext())
.resolution(Publisher.CameraCaptureResolution.LOW)
.frameRate(Publisher.CameraCaptureFrameRate.FPS_7)
.name(name)
.build();
mPublisher.setPublisherListener(VideoCallFragment.this);
mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
mPublisher.setPublishAudio(true);
mPublisher.setPublishVideo(true);
flSubStream.addView(mPublisher.getView());
if (mPublisher.getView() instanceof GLSurfaceView) {
((GLSurfaceView) mPublisher.getView()).setZOrderOnTop(true);
}
ivFlipCamera.bringToFront();
mSession.publish(mPublisher);
}
一旦 glsurface 得到 renderend 它就会出现在顶部并且旋转图标会回来。为了恢复图标,我使用了 bringtoFront() 但这不起作用。下面是布局的xml。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_frag_audio_call"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg">
<FrameLayout
android:id="@+id/container_main_streaming"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_call_time"
style="@style/NormalTextView"
android:layout_width="0dp"
android:layout_height="@dimen/height_call_timer"
android:layout_marginTop="4dp"
android:background="@color/colorTransBlack"
android:gravity="center"
android:text="@string/dummy_call_duration"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:padding="@dimen/default_app_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/default_quarter_app_margin"
android:background="@color/colorTransBlack"
app:layout_constraintBottom_toTopOf="@+id/group"
app:layout_constraintStart_toStartOf="parent">
<RelativeLayout
android:id="@+id/container_stream"
android:layout_width="@dimen/sub_streaming_size"
android:layout_height="@dimen/sub_streaming_size"
app:layout_constraintBottom_toTopOf="@+id/tv_stream_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</RelativeLayout>
<ImageView
android:id="@+id/iv_flip_camera"
android:layout_width="@dimen/camera_flip_size"
android:layout_height="@dimen/camera_flip_size"
android:src="@drawable/call_camera_flip_ico"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_stream_name"
style="@style/SmallTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/default_half_app_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="@dimen/calling_options_group_height"
android:background="@color/colorTransBlack"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageView
android:tag="1"
android:id="@+id/iv_video_switch"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_speaker"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_vid_ico" />
<ImageView
android:id="@+id/iv_mic"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_chat"
app:layout_constraintStart_toEndOf="@+id/iv_speaker"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_mic_ico" />
<ImageView
android:id="@+id/iv_chat"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_add_user"
app:layout_constraintStart_toEndOf="@+id/iv_mic"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_chat_dis_ico" />
<ImageView
android:id="@+id/iv_add_user"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_end_call"
app:layout_constraintStart_toEndOf="@+id/iv_chat"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_adduser_off_ico" />
<ImageView
android:id="@+id/iv_end_call"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_add_user"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_incoming_reject_ico" />
<ImageView
android:id="@+id/iv_speaker"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_mic"
app:layout_constraintStart_toEndOf="@+id/iv_video_switch"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_speaker_ico_enable" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
知道如何在 GLsurfaceview 上添加旋转图标吗?
【问题讨论】:
标签: android opentok glsurfaceview