add[声望升级-单人pk,进入直播间逻辑,单人PK逻辑]

This commit is contained in:
Martin 2024-04-25 14:13:25 +08:00
parent 8228c45a4d
commit 9320d6c209
17 changed files with 579 additions and 236 deletions

View File

@ -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

View File

@ -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-加入对方主播直播间

View File

@ -1000,6 +1000,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
//多人PK接受
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
L.eSw("onLinkDRMicPkApplyOk(UserBean u)");
if (mLiveLinkMicPkPresenter != null) {
mLiveLinkMicPkPresenter.onLinkDRMicPkApplyOk(u);
}

View File

@ -31,6 +31,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.facebook.appevents.AppEventsLogger;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.enums.PopupPosition;
@ -566,7 +567,9 @@ public class LiveAudienceActivity extends LiveActivity {
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
L.eSw("onLinkDRMicPkApplyOk:"+u.getId());
//多人PK 连麦
manager.getmLivePlayViewHolder().setDrMicInfo(u);
}
@Override
@ -1446,7 +1449,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (manager.getmLivePlayViewHolder() != null) {
manager.getmLivePlayViewHolder().setPkEndview();
manager.setPkStatus(false);
manager.mLivePlayViewHolder.endPk();
}
if (manager != null) {
manager.removeDetailView();

View File

@ -222,27 +222,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
Bus.getOn(this);
Intent intent = getIntent();
initFaceManager();
RCRTCEngine.getInstance().registerStatusReportListener(new IRCRTCStatusReportListener() {
@Override
public void onConnectionStats(StatusReport statusReport) {
//视频发送信息
for (Map.Entry<String, StatusBean> entry : statusReport.statusVideoSends.entrySet()) {
StatusBean statusBean = entry.getValue();
//获取userID
String userId = statusBean.uid;
//获取视频 宽x高@帧率
String resolution = statusBean.frameWidth + "x" + statusBean.frameHeight + "@" + statusBean.frameRate;
//获取码率
long bitRate = statusBean.bitRate;
//丢包率
long lossRate = statusBean.packetLostRate;
//带宽
String googAvailableSendBandwidth = statusReport.googAvailableSendBandwidth;
// Log.e("网速和内存", "获取视频:" + resolution + " 丢包率:" + lossRate + " 带宽:" + googAvailableSendBandwidth);
}
}
});
leave_img = findViewById(R.id.leave_img);
mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY);
mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG);
@ -1452,6 +1431,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
//多人PK接受
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
L.eSw("onLinkDRMicPkApplyOk111111");
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkDRMicPkApplyOk(u);
}
@ -1712,7 +1692,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
break;
case DISCONNEXT_PK_TIME:
if (mLivePushViewHolder != null) {
mLivePushViewHolder.changeToBig();
//mLivePushViewHolder.changeToBig();
mLivePushViewHolder.anchorClose();
mLiveRyLinkMicPkPresenter.leaveDRRoom();
}
break;

View File

@ -29,6 +29,7 @@ import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
@ -357,6 +358,8 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
*/
public void onLinkDRMicPkApplyOk(UserBean u) {
L.eSw("public void onLinkDRMicPkApplyOk(UserBean u) {");
user.add(u);
Log.i("1111", "12222222a" + user.size());
mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();

View File

@ -29,6 +29,7 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
@ -99,6 +100,7 @@ import cn.rongcloud.rtc.base.RCRTCMediaType;
import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RCRTCStream;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
@ -515,9 +517,31 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
* 主播与主播PK 主播收到其他主播发过来的多人PK申请同意了的回调
*/
public void onLinkDRMicPkApplyOk(UserBean u) {
if(livePushRyViewHolder!=null){
livePushRyViewHolder.setAnDrPkRtc(String.valueOf(u.getId()),-1);
L.eSw("onLinkDRMicPkApplyOk(UserBean u) " + u.getUserNiceName());
int index = 0;
if (livePushRyViewHolder != null) {
livePushRyViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1);
}
HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", CommonAppConfig.getInstance().getUid()).execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if(info.length>0){
JSONObject obj = JSONObject.parseObject(info[0]);
drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
int removeIndex = -1;
for (int i = 0; i < drPkbeans.size(); i++) {
if (CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
removeIndex = i;
}
}
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
}
dRjoinOtherRoom(drPkbeans);
}
}
});
}
/**
@ -815,79 +839,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
}
});
for (int i = 0; i < inputStreamList.size(); i++) {
Log.e("ry", "退出多人ID" + inputStreamList.get(i).getUserId());
//退出副房间
RCRTCEngine.getInstance().leaveOtherRoom(inputStreamList.get(i).getUserId(), true, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "退出多人成功");
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", "退出多人失败" + rtcErrorCode);
}
});
}
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
//视频输出配置
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
//大流视频的输出参数
RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout();
videoConfig.setVideoLayout(normal);
//推荐宽帧率参数值可以通过默认视频流的配置获取也可以根据实际需求来自定义设置
//如不设置宽高值则服务端将使用默认宽高 360 * 640
//:发布的视频分辨率为720 * 1280如果不设置则观众端看到的视频分辨率为 360 * 640,
//所以如果想让观众端看到的视频分辨率和发布视频分辨率一致则应从发布的视频流中获取分辨率配置并设置到 mediaConfig
RCRTCVideoStreamConfig defaultVideoConfig = RCRTCEngine.getInstance().getDefaultVideoStream().getVideoConfig();
int fps = defaultVideoConfig.getVideoFps().getFps();
int width = 720;
int height = 1280;
normal.setWidth(width); //视频宽
normal.setHeight(height); //视频高
normal.setFps(fps); //视频帧率
//2. 合流画布设置
//(请参照画布和声音配置示例代码)
//3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高
ArrayList<RCRTCMixConfig.CustomLayoutList.CustomLayout> list = new ArrayList<>();
config.setCustomLayouts(list);
//user1的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
list.add(videoLayout1);
videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video
videoLayout1.setX(0); //X 坐标
videoLayout1.setY(0); //Y 坐标
videoLayout1.setWidth(720); // 视频窗口的宽
videoLayout1.setHeight(1280); // 视频窗口的高
//2. 合流画布设置
if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功15");
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
}
});
}
leaveHandler.post(leaveRunnable);
livePushRyViewHolder.exitChannelDrPk(drPkbeans);
leaveHandler.removeCallbacks(leaveRunnable);
}
private Handler leaveHandler = new Handler(Looper.getMainLooper());
@ -895,15 +848,12 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
@Override
public void run() {
//恢复全屏画面
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.topMargin = 0;
livePushRyViewHolder.camera.setLayoutParams(params);
livePushRyViewHolder.dr_pk_view.setVisibility(View.GONE);
inputStreamList.clear();
inputStreamList1.clear();
//删除之前其他主播的画面
livePushRyViewHolder.dr1_preview.removeAllViews();
livePushRyViewHolder.dr2_preview.removeAllViews();
livePushRyViewHolder.dr3_preview.removeAllViews();
livePushRyViewHolder.dr4_preview.removeAllViews();
livePushRyViewHolder.cameraPreview3.removeAllViews();
leaveHandler.removeCallbacks(leaveRunnable);
livePushRyViewHolder.timeTitle.setVisibility(View.GONE);
@ -1027,6 +977,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
LiveNetManager.get(mContext).setBanRandomPK(null);
}
/**
* 显示申请多人PK的弹窗
*/
@ -1072,22 +1023,27 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
@Override
public void onSuccess(int code, String msg, String[] info) {
L.eSw("多人PK"+ "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
L.eSw("多人PK" + "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
if (info.length == 0) {
return;
}
JSONObject obj = JSONObject.parseObject(info[0]);
drPkbeans = JSONObject.parseArray(obj.getString("userlist"),DrPkbean.class);
for (int i = 0; i <drPkbeans.size(); i++) {
if(!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))){
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LIVE_DRPK)
.param("action", 2)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("pkuid", drPkbeans.get(i).getId())
.param("uid", CommonAppConfig.getInstance().getUid())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
//将自己从多人pk列表里剔除
int removeIndex = -1;
for (int i = 0; i < drPkbeans.size(); i++) {
if (CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
removeIndex = i;
}
}
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
}
for (int i = 0; i < drPkbeans.size(); i++) {
if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 2).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", drPkbeans.get(i).getId()).param("uid", CommonAppConfig.getInstance().getUid()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create();
String targetId = "g" + drPkbeans.get(i).getId();
@ -1114,12 +1070,13 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
}
});
//dRjoinOtherRoom(u.getId(), 1);
livePushRyViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()),i+2);
//
int index = livePushRyViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1);
L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 " + u.getUserNiceName());
}
}
dRjoinOtherRoom(drPkbeans);
/*for (int i = 0; i < users.size(); i++) {
JSONObject user = users.getJSONObject(i);
@ -1127,17 +1084,17 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) {
if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) {
*//**
* 向指定用户发送跨房间连麦请求
* <P>
* 1: inviterAutoMix为true时
*
* 1.1如果被邀请方在加入邀请方房间之前发布了资源当被邀请方加入邀请者房间成功后服务器会把被邀请方流资源合并到邀请方视图 ·默认仅悬浮布局合流
*
* 1.2如果被邀请方在加入邀请方房间之前没有发布过资源将会在被邀请方发布资源成功后服务器会把被邀请方流资源合并到邀请方视图默认仅悬浮布局合流
*
* 2:无论为true或false双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
* <P/>
*//*
* 向指定用户发送跨房间连麦请求
* <P>
* 1: inviterAutoMix为true时
*
* 1.1如果被邀请方在加入邀请方房间之前发布了资源当被邀请方加入邀请者房间成功后服务器会把被邀请方流资源合并到邀请方视图 ·默认仅悬浮布局合流
*
* 1.2如果被邀请方在加入邀请方房间之前没有发布过资源将会在被邀请方发布资源成功后服务器会把被邀请方流资源合并到邀请方视图默认仅悬浮布局合流
*
* 2:无论为true或false双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
* <P/>
*//*
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
@Override
public void onSuccess() {
@ -1264,57 +1221,217 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
//多人PK接受申请画 加入副房间
public void dRjoinOtherRoom(String uid, int i) {
Log.e("ry", uid + "洒洒" + i + "VVVV" + i);
mApplyUid = uid;
/*new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
//把多人PK的View显示出来
if (livePushRyViewHolder.dr_pk_view.getVisibility() == View.GONE) {
livePushRyViewHolder.dr_pk_view.setVisibility(View.VISIBLE);
livePushRyViewHolder.dr1_preview.setVisibility(View.GONE);
livePushRyViewHolder.dr2_preview.setVisibility(View.GONE);
livePushRyViewHolder.dr3_preview.setVisibility(View.GONE);
livePushRyViewHolder.dr4_preview.setVisibility(View.GONE);
public void dRjoinOtherRoom(List<DrPkbean> drPkbeanList) {
L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList));
if (drPkbeanList.size() == 1) {
String uid = String.valueOf(drPkbeanList.get(0).getId());
//设置多人PK数据
LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView2!=null){
livePushRyViewHolder.dr2_preview.removeView(detailsView2);
}
detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
textGrade2 = detailsView2.findViewById(R.id.text_grade2);
imageGrade2.setTag(uid);
textPkName2.setText(data.getUserNicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
textGrade1 = detailsView1.findViewById(R.id.text_grade1);
textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
livePushRyViewHolder.mPreView.addView(detailsView1);
livePushRyViewHolder.dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
Log.e("ry", "多人接受成功" + uid);
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
} else if (drPkbeanList.size() == 2) {
String uid1 = String.valueOf(drPkbeanList.get(0).getId());
String uid2 = String.valueOf(drPkbeanList.get(1).getId());
//设置多人PK数据
LiveNetManager.get(mContext).getLiveInfo(uid1, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView2!=null){
livePushRyViewHolder.dr2_preview.removeView(detailsView2);
}
detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
textGrade2 = detailsView2.findViewById(R.id.text_grade2);
imageGrade2.setTag(uid1);
textPkName2.setText(data.getUserNicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
textGrade1 = detailsView1.findViewById(R.id.text_grade1);
textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
livePushRyViewHolder.dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
LiveNetManager.get(mContext).getLiveInfo(uid2, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView4!=null){
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
}
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(uid2);
textPkName4.setText(data.getUserNicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
L.eSw("第三个主播的名称 数据加载完成"+detailsLinearLayout4.getVisibility());
L.eSw("detailsLinearLayout4.getVisibility()"+detailsLinearLayout4.getVisibility());
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
} else if (drPkbeanList.size() == 3) {
String uid1 = String.valueOf(drPkbeanList.get(0).getId());
String uid2 = String.valueOf(drPkbeanList.get(1).getId());
String uid3 = String.valueOf(drPkbeanList.get(2).getId());
//设置多人PK数据
LiveNetManager.get(mContext).getLiveInfo(uid1, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView2!=null){
livePushRyViewHolder.dr2_preview.removeView(detailsView2);
}
detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
textGrade2 = detailsView2.findViewById(R.id.text_grade2);
imageGrade2.setTag(uid1);
textPkName2.setText(data.getUserNicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
L.eSw("detailsLinearLayout2.getVisibility()"+detailsLinearLayout2.getVisibility());
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
textGrade1 = detailsView1.findViewById(R.id.text_grade1);
textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
livePushRyViewHolder.dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
LiveNetManager.get(mContext).getLiveInfo(uid2, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView2!=null){
livePushRyViewHolder.dr3_preview.removeView(detailsView3);
}
detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3);
linearGrade3 = detailsView3.findViewById(R.id.linear_grade3);
textPkName3 = detailsView3.findViewById(R.id.text_pk_name3);
imageGrade3 = detailsView3.findViewById(R.id.image_grade3);
textGrade3 = detailsView3.findViewById(R.id.text_grade3);
imageGrade3.setTag(uid2);
textPkName3.setText(data.getUserNicename());
livePushRyViewHolder.dr3_preview.addView(detailsView3);
detailsLinearLayout3.setVisibility(View.VISIBLE);
linearGrade3.setVisibility(View.GONE);
L.eSw("detailsLinearLayout3.getVisibility()"+detailsLinearLayout3.getVisibility());
L.eSw("第三个主播的名称 数据加载完成");
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
LiveNetManager.get(mContext).getLiveInfo(uid3, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView4!=null){
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
}
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(uid3);
textPkName4.setText(data.getUserNicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
L.eSw("detailsLinearLayout4.getVisibility()"+detailsLinearLayout4.getVisibility());
L.eSw("第四个主播的名称 数据加载完成");
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
Log.e("ry", "多人接受成功" + mApplyUid);
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
}
//设置多人PK数据
LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
textGrade2 = detailsView2.findViewById(R.id.text_grade2);
imageGrade2.setTag(String.valueOf(uid));
textPkName2.setText(data.getUserNicename());
livePushRyViewHolder.dr1_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
Log.e("ry", "多人接受成功" + mApplyUid);
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
}
});*/
}
}
/**
* 多人PK PK主播发过来的已经接受
@ -2008,6 +2125,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
* 更新Pk分数
*/
public void upDataPkScore(JSONArray pkScores, String uid, int time) {
L.eSw("更新Pk分数 upDataPkScore time:" + time + " " + pkScores);
String userID1 = (String) imageGrade1.getTag();
String userID2 = (String) imageGrade2.getTag();
String userID4 = (String) imageGrade4.getTag();
@ -2025,7 +2143,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
mHandler.sendEmptyMessage(WHAT_PK_TIME2);
}
}
int pkScoreSize = pkScores.size();
if (pkScoreSize == 3) {

View File

@ -312,6 +312,7 @@ public class SocketRyClient {
UserBean u = new UserBean();
// u.setUserNiceName(map.getString("uname"));
u.setId(map.getString("uid"));
L.eSw("action3 == 2:"+u.getId());
mListener.onLinkDRMicPkApplyOk(u);
} else if (action3 == 6) {//开始Pk
if (LiveRoomViewHolder.mHandler != null) {
@ -334,7 +335,6 @@ public class SocketRyClient {
} else {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW));
}
//創建了多人房間
} else if (action3 == 3) {

View File

@ -11,15 +11,25 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.tencent.live2.V2TXLiveDef;
import com.tencent.live2.V2TXLivePlayer;
import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.live.R;
import com.yunbao.live.bean.DrPkbean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cxf on 2018/10/10.
@ -48,7 +58,6 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
public static int landscape; //1h 2s
public static Context contexts;
int screenWidth; // 屏幕宽像素480px
int screenHeight; // 屏幕高像素800p
@ -254,6 +263,10 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
}
}
@Override
public void setDrMicInfo(UserBean u) {
}
@Override
public void setLiveBeanLandscape(int landscape) {
LivePlayKsyViewHolder.landscape =landscape;

View File

@ -19,13 +19,16 @@ import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSONObject;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.google.android.exoplayer2.video.VideoSize;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.interfaces.XPopupCallback;
@ -33,6 +36,7 @@ import com.lzf.easyfloat.EasyFloat;
import com.lzy.okserver.OkDownload;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.LiveFontSizeSettingDialog;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
@ -51,6 +55,7 @@ import com.yunbao.common.views.LiveClarityCustomPopup;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.bean.DrPkbean;
import com.yunbao.live.event.LiveAudienceEvent;
import org.greenrobot.eventbus.EventBus;
@ -130,6 +135,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
SWAuManager swAuManager;
String liveUid;
private LinearLayout dr_pk_view;
private FrameLayout dr1_preview;
private FrameLayout dr2_preview;
private FrameLayout dr3_preview;
private FrameLayout dr4_preview;
public int getLandscape() {
return landscape;
}
@ -175,6 +186,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
debugView = new TextView(mContext);
debugView.setBackgroundColor(Color.WHITE);
dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
dr1_preview = (FrameLayout) findViewById(R.id.dr1_preview);
dr2_preview = (FrameLayout) findViewById(R.id.dr2_preview);
dr3_preview = (FrameLayout) findViewById(R.id.dr3_preview);
dr4_preview = (FrameLayout) findViewById(R.id.dr4_preview);
dr_pk_view.setVisibility(View.GONE);
}
public void initSwEngine(String liveUid) {
@ -188,6 +206,80 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(liveUid));
}
/**
* 开启单人PK
* @param Uid
*/
public void setPkView(String Uid) {
swAuManager.updateMyChannelView((FrameLayout) mLeftContainer, Integer.parseInt(liveUid));
ry_view.removeAllViews();
//加入对方主播房间
swAuManager.setPkContainer1((FrameLayout) mRightContainer);
swAuManager.joinExRoomEx(Integer.parseInt(Uid), CommonAppConfig.SWToken, SWAuManager.getChannelName(Uid));
}
List<UserBean> drMicUserList = new ArrayList<>();
boolean isAdd = true;
@Override
public void setDrMicInfo(UserBean u) {
L.eSw("setDrMicInfo:"+u.getId()+" drMicUserList:"+new Gson().toJson(drMicUserList));
for (int i = 0; i <drMicUserList.size(); i++) {
if(u.getId().equals(drMicUserList.get(i).getId())){
isAdd = false;
}
}
//加载多人PK(连麦)主播视图
if(isAdd){
dr_pk_view.setVisibility(View.VISIBLE);
drMicUserList.add(u);
if(drMicUserList.size()==1){
ry_view.removeAllViews();
swAuManager.updateMyChannelView((FrameLayout) dr1_preview, Integer.parseInt(liveUid));
swAuManager.joinChannelDrEx(dr2_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, u.getId(),SWAuManager.getChannelName(u.getId()));
dr3_preview.setVisibility(View.GONE);
dr4_preview.setVisibility(View.GONE);
}else if(drMicUserList.size()==2){
dr3_preview.setVisibility(View.GONE);
dr4_preview.setVisibility(View.VISIBLE);
swAuManager.joinChannelDrEx(dr4_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, u.getId(),SWAuManager.getChannelName(u.getId()));
}else if(drMicUserList.size()==3){
dr4_preview.setVisibility(View.VISIBLE);
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drMicUserList.get(1).getId());
swAuManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, drMicUserList.get(1).getId(),SWAuManager.getChannelName(drMicUserList.get(1).getId()));
swAuManager.joinChannelDrEx(dr4_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, drMicUserList.get(2).getId(),SWAuManager.getChannelName(drMicUserList.get(2).getId()));
}
}
}
/**
* 退出单人pk
* @param pkUid
*/
public void endpk(String pkUid) {
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid));
swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid));
mLeftContainer.removeAllViews();
mRightContainer.removeAllViews();
}
/**
* 退出所有连麦主播的房間
*/
public void endPk(){
dr_pk_view.setVisibility(View.GONE);
dr1_preview.removeAllViews();
dr2_preview.removeAllViews();
dr3_preview.removeAllViews();
dr4_preview.removeAllViews();
//退出所有连麦主播的房間
for (int i = 0; i <drMicUserList.size(); i++) {
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drMicUserList.get(i).getId());
}
//將當前主播畫面放大
swAuManager.updateMyChannelView((FrameLayout) ry_view, Integer.parseInt(liveUid));
}
@Override
public void hideCover() {
// if (mCover != null) {
@ -414,11 +506,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void setViewUP(int i) {
if (mVideoView == null) return;
Log.e("PK状态", "" + i);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
params.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
/*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight;
@ -530,6 +618,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
// }
}
public void removeDetailView() {
// if (detailsView != null) {
// mVideoView.removeView(detailsView);
@ -859,22 +948,15 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
}).showDialog();
} else if (event.getType() == LiveAudienceEvent.LiveAudienceType.PK_TWO_START) {
//将当前主播画面换个画布展示
swAuManager.updateMyChannelView((FrameLayout) mLeftContainer, Integer.parseInt(liveUid));
ry_view.removeAllViews();
//加入对方主播房间
swAuManager.setPkContainer1((FrameLayout) mRightContainer);
String pkUid = (String) event.getObject();
swAuManager.joinExRoomEx(Integer.parseInt(pkUid), CommonAppConfig.SWToken, SWAuManager.getChannelName(pkUid));
setPkView(pkUid);
} else if (event.getType() == LiveAudienceEvent.LiveAudienceType.LIVE_PK_END) {
String pkUid = (String) event.getObject();
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid));
swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid));
mLeftContainer.removeAllViews();
mRightContainer.removeAllViews();
//endpk(pkUid);
}
}
/**
* 把观众转换成主播
*/

View File

@ -18,6 +18,7 @@ import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLivePlayConfig;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.L;
@ -69,6 +70,11 @@ public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXL
}
@Override
public void setDrMicInfo(UserBean u) {
}
@Override
public void setLiveBeanLandscape(int landscape) {
}

View File

@ -18,6 +18,7 @@ import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePlayConfig;
import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.DpUtil;
@ -66,6 +67,11 @@ public class LivePlayTxViewHolder_backup extends LiveRoomPlayViewHolder implemen
}
@Override
public void setDrMicInfo(UserBean u) {
}
@Override
public void setLiveBeanLandscape(int landscape) {

View File

@ -56,6 +56,7 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.bean.DrPkbean;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.common.http.LiveHttpConsts;
import com.yunbao.common.http.LiveHttpUtil;
@ -284,7 +285,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), true, true, "LiveDRPK1", new IRCRTCResultCallback() {
@Override
public void onSuccess() {
mLiveRyLinkMicPkPresenter.dRjoinOtherRoom(userBean.getId(), 2);
//mLiveRyLinkMicPkPresenter.dRjoinOtherRoom(userBean.getId(), 2);
}
@Override
@ -380,7 +381,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
} else if (agree == true && extra.equals(SOCKET_LIVE_DRPK)) {
mLiveRyLinkMicPkPresenter.onDRLinkMicToPk(inviteeRoomId);
} else if (extra.equals("LiveDRPK1")) {
mLiveRyLinkMicPkPresenter.dRjoinOtherRoom(inviteeRoomId, 3);
//mLiveRyLinkMicPkPresenter.dRjoinOtherRoom(inviteeRoomId, 3);
} else {
Log.e("ry", extra);
UserBean userBean1 = new UserBean();
@ -575,6 +576,14 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
});
}
public void exitChannelDrPk(List<DrPkbean> drPkbeanList){
for (int i = 0; i <drPkbeanList.size(); i++) {
if(!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeanList.get(i).getId()))){
SWManager.get().exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), String.valueOf(drPkbeanList.get(i).getId()));
}
}
SWManager.get().updateMyChannelView((FrameLayout) mBigContainer);
}
public void setAnPkRtc(UserBean u) {
if (swManager != null && u != null) {
@ -582,9 +591,9 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
//将自己的渲染视图设置到 leftContainer
swManager.updateMyChannelView((FrameLayout) mLeftContainer);
//清除 mBigContainer 中的渲染
mBigContainer.removeAllViews();
btn_close.setVisibility(View.VISIBLE);
//设置对方主播的渲染视图 设置到 rightContainer
swManager.setPkContainer(mRightContainer);
@ -595,7 +604,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
private int currentPosition = 0;
private String drpkUid3 = "";
public void setAnDrPkRtc(String uid, int position) {
public int setAnDrPkRtc(String uid, int position) {
FrameLayout frameLayout = null;
int temp= -1;
if (swManager != null && !StringUtil.isEmpty(uid)) {
@ -621,11 +630,10 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
break;
case 4:
dr3_preview.setVisibility(View.VISIBLE);
//將f3->f4 f4->f3
dr3_preview.removeAllViews();
swManager.updateDrChannelView(dr3_preview,SWAuManager.getChannelName(drpkUid3),drpkUid3);
//先退出这个主播的直播间在进入该直播间视图问题暂时找不到解决方案
swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drpkUid3);
swManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3));
dr4_preview.removeAllViews();
frameLayout = dr4_preview;
break;
}
@ -635,18 +643,23 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
mBigContainer.removeAllViews();
}
swManager.joinChannelDrEx(frameLayout,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid));
btn_close.setVisibility(View.VISIBLE);
dr_pk_view.setVisibility(View.VISIBLE);
currentPosition = temp;
}
return currentPosition;
}
public void anchorClose(){
swManager.updateMyChannelView((FrameLayout) mBigContainer); //用户主动断开连麦再退出画面
}
public void onLinkMicAnchorClose() {
swManager.updateMyChannelView((FrameLayout) mBigContainer);
LivePushRyViewHolder.btn_close.setVisibility(View.GONE);
//swManager.updateMyChannelView((FrameLayout) mBigContainer); 用户主动断开连麦再退出画面
//LivePushRyViewHolder.btn_close.setVisibility(View.GONE);
}
public void onLinkDRMicPkApply(UserBean userBean) {
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);

View File

@ -6,6 +6,7 @@ import android.view.ViewGroup;
import com.alibaba.fastjson.JSONArray;
import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.live.interfaces.ILiveLinkMicViewHolder;
@ -70,6 +71,8 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
public abstract void setPkEndview();
public abstract void setDrMicInfo(UserBean u);
public abstract void setLiveBeanLandscape(int landscape);
public void setLiveBean(LiveBean data) {
@ -79,6 +82,17 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
public void setViewUP(int i) {
}
public void setViewPkMic(int uid) {
}
public void setViewPk() {
}
public void setViewDrMic() {
}
public void setViewDrPk() {
}
public OnMicCallback getOnMicCallback() {
return onMicCallback;
}

View File

@ -73,6 +73,7 @@ import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RandomUtil;
import com.yunbao.common.utils.RouteUtil;
@ -84,6 +85,7 @@ import com.yunbao.common.views.weight.LiveFloatView;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.bean.DrPkbean;
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
import com.yunbao.live.bean.LiveChatBean;
import com.yunbao.live.bean.LiveDanMuBean;
@ -150,7 +152,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//侧滑布局
// private DrawerLayout drawerLayout;
//直播间拆分布局
private LivePlayRyViewHolder mLivePlayViewHolder;
public LivePlayRyViewHolder mLivePlayViewHolder;
//头部布局
public LiveRoomViewHolder mLiveRoomViewHolder;
//底部布局
@ -641,16 +643,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
if (mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) {
mLivePlayViewHolder.setViewUP(1);
//mLivePlayViewHolder.setViewUP(1);
mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid());
}
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = false;
}
if (mLivePlayViewHolder != null && pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了
mLivePlayViewHolder.setViewUP(2);
mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid());
//pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
@ -662,7 +663,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mLiveRoomViewHolder != null && pkInfo != null && pkInfo.containsKey("pkuid") && pkInfo.containsKey("pkuimg") && pkInfo.containsKey("pkuname")) {
mLiveRoomViewHolder.setOtherInfo(pkInfo.getString("pkuid"), pkInfo.getString("pkuimg"), pkInfo.getString("pkuname"));
}
}
};
linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);
@ -676,7 +676,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.initPkRank(null);
}
if (mLivePlayViewHolder != null) {
mLivePlayViewHolder.setViewUP(3);
//mLivePlayViewHolder.setViewUP(3);
mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid());
}
//pk排名数据
@ -693,7 +694,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.initPkRank(null);
}
if (mLivePlayViewHolder != null) {
mLivePlayViewHolder.setViewUP(4);
JSONArray array = pkInfo.getJSONArray("userlist");
for (int j = 0; j < array.size(); j++) {
UserBean drPkbean = new UserBean();
JSONObject da = array.getJSONObject(j);
drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean);
}
}
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
@ -1561,7 +1568,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
L.eSw("onLinkDRMicPkApplyOk(UserBean u)PortraitLiveManager");
mLivePlayViewHolder.setDrMicInfo(u);
}
@ -1627,6 +1635,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
if (mLiveRoomViewHolder != null) {
mLivePlayViewHolder.setLiveBeanLandscape(landscape);
mLivePlayViewHolder.endpk(mPkUid);
}
if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).setPkStatus(false);
@ -2153,6 +2162,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* @param time
*/
public void upDataPkScore(JSONArray pkScores, int time) {
if (mLiveRoomViewHolder != null) {
String liveId = mLiveBean.getUid();
JSONObject liveModel = null;

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -65,7 +66,61 @@
android:layout_marginBottom="20dp" />
</FrameLayout>
<LinearLayout
android:id="@+id/dr_pk_view"
android:layout_width="match_parent"
android:layout_height="270dp"
android:layout_marginTop="130dp"
android:orientation="horizontal"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<FrameLayout
android:id="@+id/dr1_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@mipmap/live_icon_vacancy"
tools:ignore="NestedWeights" />
<FrameLayout
android:id="@+id/dr3_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@mipmap/live_icon_vacancy" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<FrameLayout
android:id="@+id/dr2_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@mipmap/live_icon_vacancy"
tools:ignore="NestedWeights" />
<FrameLayout
android:id="@+id/dr4_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@mipmap/live_icon_vacancy" />
</LinearLayout>
</LinearLayout>
<com.yunbao.live.custom.MyFrameLayout3
android:id="@+id/small_container"

View File

@ -43,7 +43,7 @@
android:layout_height="270dp"
android:layout_marginTop="130dp"
android:orientation="horizontal"
android:visibility="visible">
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
@ -160,13 +160,12 @@
android:layout_width="match_parent"
android:layout_height="270dp"
android:layout_marginTop="130dp">
<com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/left_container"
android:layout_marginBottom="20dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="20dp" />
/>
<com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/right_container"
android:layout_width="0dp"