6868public class SwitchExternalVideo extends BaseFragment implements View .OnClickListener {
6969 private static final String TAG = SwitchExternalVideo .class .getSimpleName ();
7070
71- private FrameLayout fl_remote ;
7271 private RelativeLayout fl_local ;
7372 private Button join , localVideo ;
7473 private EditText et_channel ;
@@ -101,7 +100,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
101100 join = view .findViewById (R .id .btn_join );
102101 localVideo = view .findViewById (R .id .localVideo );
103102 et_channel = view .findViewById (R .id .et_channel );
104- fl_remote = view .findViewById (R .id .fl_remote );
105103 fl_local = view .findViewById (R .id .fl_local );
106104 join .setOnClickListener (this );
107105 localVideo .setOnClickListener (this );
@@ -193,7 +191,6 @@ public void onClick(View v) {
193191 joined = false ;
194192 join .setText (getString (R .string .join ));
195193 localVideo .setEnabled (false );
196- fl_remote .removeAllViews ();
197194 fl_local .removeAllViews ();
198195 /**After joining a channel, the user must call the leaveChannel method to end the
199196 * call before joining another channel. This method returns 0 if the user leaves the
@@ -417,26 +414,26 @@ public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
417414 public void onRemoteVideoStateChanged (int uid , int state , int reason , int elapsed ) {
418415 super .onRemoteVideoStateChanged (uid , state , reason , elapsed );
419416 Log .i (TAG , "onRemoteVideoStateChanged:uid->" + uid + ", state->" + state );
420- if (state == REMOTE_VIDEO_STATE_STARTING ) {
421- /**Check if the context is correct*/
422- Context context = getContext ();
423- if (context == null ) {
424- return ;
425- }
426- handler .post (() ->
427- {
428- /**Display remote video stream*/
429- SurfaceView surfaceView = RtcEngine .CreateRendererView (context );
430- surfaceView .setZOrderMediaOverlay (true );
431- if (fl_remote .getChildCount () > 0 ) {
432- fl_remote .removeAllViews ();
433- }
434- fl_remote .addView (surfaceView , new FrameLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT ,
435- ViewGroup .LayoutParams .MATCH_PARENT ));
436- /**Setup remote video to render*/
437- ENGINE .setupRemoteVideo (new VideoCanvas (surfaceView , RENDER_MODE_HIDDEN , uid ));
438- });
439- }
417+ // if (state == REMOTE_VIDEO_STATE_STARTING) {
418+ // /**Check if the context is correct*/
419+ // Context context = getContext();
420+ // if (context == null) {
421+ // return;
422+ // }
423+ // handler.post(() ->
424+ // {
425+ // /**Display remote video stream*/
426+ // SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
427+ // surfaceView.setZOrderMediaOverlay(true);
428+ // if (fl_remote.getChildCount() > 0) {
429+ // fl_remote.removeAllViews();
430+ // }
431+ // fl_remote.addView(surfaceView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
432+ // ViewGroup.LayoutParams.MATCH_PARENT));
433+ // /**Setup remote video to render*/
434+ // ENGINE.setupRemoteVideo(new VideoCanvas(surfaceView, RENDER_MODE_HIDDEN, uid));
435+ // });
436+ // }
440437 }
441438
442439 /**Occurs when a remote user (Communication)/host (Live Broadcast) joins the channel.
@@ -463,17 +460,17 @@ public void onUserJoined(int uid, int elapsed) {
463460 @ Override
464461 public void onUserOffline (int uid , int reason ) {
465462 Log .i (TAG , String .format ("user %d offline! reason:%d" , uid , reason ));
466- showLongToast (String .format ("user %d offline! reason:%d" , uid , reason ));
467- handler .post (new Runnable () {
468- @ Override
469- public void run () {
470- /**Clear render view
471- Note: The video will stay at its last frame, to completely remove it you will need to
472- remove the SurfaceView from its parent*/
473- ENGINE .setupRemoteVideo (new VideoCanvas (null , RENDER_MODE_HIDDEN , uid ));
474- fl_remote .removeAllViews ();
475- }
476- });
463+ // showLongToast(String.format("user %d offline! reason:%d", uid, reason));
464+ // handler.post(new Runnable() {
465+ // @Override
466+ // public void run() {
467+ // /**Clear render view
468+ // Note: The video will stay at its last frame, to completely remove it you will need to
469+ // remove the SurfaceView from its parent*/
470+ // ENGINE.setupRemoteVideo(new VideoCanvas(null, RENDER_MODE_HIDDEN, uid));
471+ // fl_remote.removeAllViews();
472+ // }
473+ // });
477474 }
478475 };
479476
0 commit comments