Skip to content

Commit

Permalink
removed release of the camera when app is in background
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Nicoli authored and Alvaro Nicoli committed May 29, 2019
1 parent 1385172 commit 6b9e743
Showing 1 changed file with 2 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,55 +229,12 @@ public void onError(int i) {

@Override
public void onHostResume() {
/*
* 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);

}
Log.i("CustomTwilioVideoView", "Host resume does nothing!!");
}

@Override
public void onHostPause() {
Log.i("CustomTwilioVideoView", "Host pause");
/*
* Release the local video track before going in the background. This ensures that the
* camera can be used by other applications while this app is in the background.
*/
if (localVideoTrack != null) {
/*
* If this local video track is being shared in a Room, remove from local
* participant before releasing the video track. Participants will be notified that
* the track has been removed.
*/
if (localParticipant != null) {
localParticipant.unpublishTrack(localVideoTrack);
}

localVideoTrack.release();
localVideoTrack = null;
}
Log.i("CustomTwilioVideoView", "Host pause does nothing");
}

@Override
Expand Down

0 comments on commit 6b9e743

Please sign in to comment.