android - 在其他表面 View 之上的圆形表面 View

标签 android video-streaming surfaceview agora.io

我的要求是使用表面 View 显示视频聊天。我的视频 View 也将包含远程 View 和本地 View 。

我能够将局部表面 View 的形状变圆,但是当远程视频 View 膨胀时,局部表面 View 会恢复到原始矩形形状。

我正在使用轮廓提供和裁剪来制作圆形的表面 View 。

这是我想要实现的快照。 Local video surface view on top of other remote video surface view

这就是我得到的:-

在远程 View 被视频膨胀之前: I can get curve shape of local view

在远程 View 被视频膨胀后: again local view came back to original shape i.e rectangular

这是我的 xml 代码:-

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_video_chat_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="io.agora.tutorials1v1vcall.VideoChatViewActivity">

    <RelativeLayout
        android:id="@+id/remote_video_view_container"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="@color/remoteBackground">


    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/local_frame"
        android:layout_width="@dimen/local_preview_width"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/remote_video_view_container">

        <FrameLayout
            android:id="@+id/local_video_view_container"
            android:layout_width="@dimen/local_preview_width"
            android:layout_height="@dimen/local_preview_height"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_marginEnd="@dimen/local_preview_margin_right"
            android:layout_marginRight="@dimen/local_preview_margin_right"
            android:background="@color/localBackground"
            android:elevation="10dp">
        </FrameLayout>
    </RelativeLayout>

这里远程表面 View 将进入@+id/remote_video_view_container

local surface view 会进入@+id/local_video_view_container 的圆圈内。

为了更多引用,我将此示例用于 1 对 1 视频聊天。 sample video chat

注意:- 我无法将自定义表面 View 创建为从第 3 方库动态获取的表面 View 实例。

任何帮助将不胜感激....

最佳答案

您应该能够使用远程的 AgoraTextureView 和本地的 SurfaceView 来实现这一点。我为展示这一点而构建的示例项目:https://slack-files.com/T1CBEDLJY-F012R1T5CL8-7425620f71

关于android - 在其他表面 View 之上的圆形表面 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64481459/

相关文章:

java - 无法执行操作,因为插入数据库时​​没有当前事务

android - 在没有监听器的情况下从 Android 传感器获取数据

html - WebRTC 回退

android - 如何使扩展 SurfaceView 的类启动 Activity?

Android Dex : [Project name] Cannot create classes. dex 文件

java - camera2 输出到位图

c# - 用于延迟 15 秒播放视频的 wpf 应用程序

c++ - 使用 IPTables 检索数据库数据表

android - 如何在 SurfaceView 上实现项目触摸

java - 如何停止 Android 中的 SurfaceView?