From f1e234516aa86d0e47fb34da72848afd49d6fdd9 Mon Sep 17 00:00:00 2001 From: Alvaro Nicoli Date: Thu, 30 May 2019 16:36:49 -0300 Subject: [PATCH] Put back the code in onHostResume --- .../library/CustomTwilioVideoView.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/twiliorn/library/CustomTwilioVideoView.java b/android/src/main/java/com/twiliorn/library/CustomTwilioVideoView.java index 85e949e2..08ae3df9 100644 --- a/android/src/main/java/com/twiliorn/library/CustomTwilioVideoView.java +++ b/android/src/main/java/com/twiliorn/library/CustomTwilioVideoView.java @@ -229,7 +229,33 @@ public void onError(int i) { @Override public void onHostResume() { - Log.i("CustomTwilioVideoView", "Host resume does nothing!!"); + /* + * In case it wasn't set. + */ + if (themedReactContext.getCurrentActivity() != null) { + /* + * If the local video track was released when the app was put in the background, recreate. + */ + if (cameraCapturer != null && localVideoTrack == null) { + localVideoTrack = LocalVideoTrack.create(getContext(), true, cameraCapturer, buildVideoConstraints()); + } + + if (localVideoTrack != null) { + if (thumbnailVideoView != null) { + localVideoTrack.addRenderer(thumbnailVideoView); + } + + /* + * If connected to a Room then share the local video track. + */ + if (localParticipant != null) { + localParticipant.publishTrack(localVideoTrack); + } + } + + themedReactContext.getCurrentActivity().setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); + + } } @Override