我正在使用本地和远程流处理GLSufaceView。我使用VideoRenderer设置远程和本地流,如下所示。
小视图是远程流媒体。我想点击远程视图交换本地和远程视频流,问题是我无法应用点击此视图。我正在使用此代码添加远程和视频流。
remoteRender = VideoRendererGui.create(REMOTE_X, REMOTE_Y, REMOTE_WIDTH, REMOTE_HEIGHT, scalingType, false);
localRender = VideoRendererGui.create(LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING, LOCAL_WIDTH_CONNECTING, LOCAL_HEIGHT_CONNECTING, scalingType, true);
当我得到我的本地流时,提到方法被称为:
@Override
public void onLocalStream(MediaStream stream) {
stream.videoTracks.get(0).addRenderer(new VideoRenderer(localRender));
VideoRendererGui.update(localRender, LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING, LOCAL_WIDTH_CONNECTING, LOCAL_HEIGHT_CONNECTING, scalingType, true);
}
当我在下面提到远程流时,提到方法被称为:
@Override
public void onAddRemoteStream(final MediaStream remoteStream, final int endPoint, final PeerConnection pc) {
remoteRender = VideoRendererGui.create(REMOTE_X_CONNECTED - 20 * (cursor - 1), y, REMOTE_WIDTH_CONNECTED, REMOTE_HEIGHT_CONNECTED, scalingType, false);
remoteStream.videoTracks.get(0).addRenderer(new VideoRenderer(remoteRender));
VideoRendererGui.update(remoteRender, REMOTE_X_CONNECTED - 20 * (cursor - 1), y, REMOTE_WIDTH_CONNECTED, REMOTE_HEIGHT_CONNECTED, scalingType, true);
}
});
}
我想仅对远程流应用点击。这两个视图都是一个GLSurfaceview的一部分。
请帮我解决这个问题。
答案 0 :(得分:1)
使用FrameLayout可能更容易使用2个表面视图,一个堆叠在另一个上面。然后,将onClickListener附加到要监听点击的那个
remoteVideoView = (GLSurfaceView) findViewById(R.id.remote_view);
localVideoView = (GLSurfaceView) findViewById(R.id.local_view);
remoteVideoView.setOnCLickListener(view -> switchStreams());