add[声望升级-单人pk,进入直播间逻辑,单人PK逻辑]
This commit is contained in:
@@ -90,7 +90,6 @@ public class SWAuManager extends BaseCacheManager {
|
||||
mRtcEngine.setupRemoteVideo(videoCanvas);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加入房间
|
||||
*/
|
||||
@@ -155,6 +154,65 @@ public class SWAuManager extends BaseCacheManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* PK-加入对方主播直播间
|
||||
* @param strUid
|
||||
* @param token
|
||||
* @param toUid
|
||||
* @param channelName
|
||||
*/
|
||||
public void joinChannelDrEx(FrameLayout frameLayout,String strUid, String token, String toUid, String channelName) {
|
||||
int tempUid;
|
||||
if (StringUtil.isEmpty(strUid)) {
|
||||
tempUid = 0;
|
||||
} else {
|
||||
tempUid = Integer.parseInt(strUid);
|
||||
}
|
||||
|
||||
// 创建 ChannelMediaOptions 对象,并进行配置
|
||||
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||
// 根据场景将用户角色设置为 AUDIENCE (观众)
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||
options.autoSubscribeVideo = true;
|
||||
options.autoSubscribeAudio = true;
|
||||
options.publishMicrophoneTrack = false;
|
||||
options.publishCameraTrack = false;
|
||||
|
||||
RtcConnection rtcConnection = new RtcConnection();
|
||||
rtcConnection.channelId = channelName; //對方主播的頻道
|
||||
rtcConnection.localUid = tempUid;//自己的ID
|
||||
L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName);
|
||||
mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
|
||||
@Override
|
||||
public void onJoinChannelSuccess(String channel, int scUid, int elapsed) {
|
||||
super.onJoinChannelSuccess(channel, scUid, elapsed);
|
||||
L.eSw("onJoinChannelSuccess:" + channel + " uid " + scUid + " elapsed: " + elapsed);
|
||||
mContext.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||
surfaceView.setZOrderMediaOverlay(true);
|
||||
frameLayout.addView(surfaceView);
|
||||
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT,Integer.parseInt(toUid));
|
||||
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeaveChannel(RtcStats stats) {
|
||||
super.onLeaveChannel(stats);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int err) {
|
||||
super.onError(err);
|
||||
L.eSw("onError:" + err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出对方直播间
|
||||
* @param uid 自己的ID
|
||||
|
||||
@@ -134,6 +134,8 @@ public class SWManager extends BaseCacheManager {
|
||||
faceUnityBeautyAPI.setupLocalVideo(surfaceView, Constants.RENDER_MODE_HIDDEN);
|
||||
//faceUnityBeautyAPI.updateCameraConfig(new CameraConfig(MirrorMode.MIRROR_NONE,MirrorMode.MIRROR_NONE));
|
||||
//mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
|
||||
setEnableBeauty(true); //默认开启美颜
|
||||
|
||||
}
|
||||
|
||||
public void setEnableBeauty(boolean flag){
|
||||
@@ -279,26 +281,6 @@ public class SWManager extends BaseCacheManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新主播视图
|
||||
* @param frameLayout
|
||||
* @param channelName 對方直播間通道
|
||||
* @param toUid 對方主播uid
|
||||
*/
|
||||
public void updateDrChannelView(FrameLayout frameLayout,String channelName,String toUid) {
|
||||
mRtcEngine.setupLocalVideo(null);
|
||||
|
||||
RtcConnection rtcConnection = new RtcConnection();
|
||||
rtcConnection.channelId = channelName; //對方主播的頻道
|
||||
rtcConnection.localUid = Integer.parseInt(CommonAppConfig.getInstance().getUid());//自己的ID
|
||||
|
||||
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||
surfaceView.setZOrderMediaOverlay(true);
|
||||
frameLayout.addView(surfaceView);
|
||||
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT,Integer.parseInt(toUid));
|
||||
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PK-加入对方主播直播间
|
||||
|
||||
Reference in New Issue
Block a user