Round corner Twilio VideoView on android

Viewed 718

I am having a hard time with the Android SDK for Twilio video call to have a consistent round corner for my view. In this videoView I display my screen. With the following piece of code, it works fine UNTIL another participant joins the room.
For some reason, my VideoView is not round anymore, but square.

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/videoContent"
android:layout_width="110dp"
android:layout_height="160dp"
app:cardCornerRadius="30dp">

<com.twilio.video.VideoView
    android:id="@+id/thumbnailVideoView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:tviMirror="true"
    app:tviOverlaySurface="true" />

...
</androidx.cardview.widget.CardView>

Those 2 views are not modified by myself at any moment.

I think it's quite related to this issue on IOS: https://github.com/twilio/video-quickstart-ios/issues/106

However, I did not find anything similar on Android.

When I connect with an emulator to the same room : When I connect with an emulator to the same room

When there is no one in the room (or remove the camera) :

When there is no one in the room (or remove the camera)

Any clue?

1 Answers

VideoView is an implementation of the View that behaves as a floating-above window, as a result it just draws on top of you CardView with the appropriate sizing, but ignoring any rounded corners.

In order to get it working I suggest you try substituting your VideoView with VideoTextureView, which behaves as a regular view and will apply constraints you put on it through CardView.

From Twilio changelog:

VideoTextureView is similar to VideoView but subclasses TextureView instead of SurfaceView. Unlike SurfaceView, TextureView does not create a separate window but behaves as a regular View. This key difference allows a TextureView to be moved, transformed, animated, etc. https://www.twilio.com/docs/video/changelog-twilio-video-android-3x

Related