add[声望升级]
This commit is contained in:
@@ -124,10 +124,6 @@
|
||||
<activity
|
||||
android:name=".activity.CompensateActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.NewLiveActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -3,6 +3,7 @@ package com.yunbao.live.activity;
|
||||
import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
|
||||
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
|
||||
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
|
||||
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
|
||||
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
|
||||
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK_RANDOM;
|
||||
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_dr_pk_nub;
|
||||
@@ -101,6 +102,7 @@ import com.yunbao.live.interfaces.LiveFunctionClickListener;
|
||||
import com.yunbao.live.interfaces.LivePushListener;
|
||||
import com.yunbao.live.music.LiveMusicDialogFragment;
|
||||
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
|
||||
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
|
||||
import com.yunbao.live.presenter.LiveLinkMicPresenter;
|
||||
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
|
||||
import com.yunbao.live.socket.SocketRyChatUtil;
|
||||
@@ -1235,8 +1237,40 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
if (obj != null) {
|
||||
if (obj.getString("ispk").equals("0")) {
|
||||
|
||||
// TODO: 2024/4/11 发送IM消息
|
||||
final SocketSendBean msg1 = new SocketSendBean()
|
||||
.param("_method_", SOCKET_LINK_MIC_PK)
|
||||
.param("action", 1)
|
||||
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
|
||||
.param("pkuid", pkUid)
|
||||
.param("uid", CommonAppConfig.getInstance().getUid())
|
||||
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
|
||||
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
||||
msg1.create();
|
||||
|
||||
IMRTCManager.getInstance().requestJoinOtherRoom(pkUid, true, extra, new IRCRTCResultCallback() {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain("g" + pkUid, conversationType, messageContent);
|
||||
|
||||
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(io.rong.imlib.model.Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(io.rong.imlib.model.Message message) {
|
||||
Log.e("tx", "发送成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
|
||||
Log.e("tx", "发送失败" + errorCode.getMessage());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/*IMRTCManager.getInstance().requestJoinOtherRoom(pkUid, true, extra, new IRCRTCResultCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// ToastUtil.show("邀请 " + pkUid + " 发送成功");
|
||||
@@ -1264,7 +1298,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
ToastUtil.show("invite " + pkUid + " failed:" + rtcErrorCode);
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
|
||||
} else {
|
||||
ToastUtil.show("主播正在PK,稍後再試");
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.view.SurfaceView;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.yunbao.common.manager.SWManager;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import io.agora.rtc2.ChannelMediaOptions;
|
||||
import io.agora.rtc2.Constants;
|
||||
import io.agora.rtc2.IRtcEngineEventHandler;
|
||||
import io.agora.rtc2.RtcEngine;
|
||||
import io.agora.rtc2.RtcEngineConfig;
|
||||
import io.agora.rtc2.video.VideoCanvas;
|
||||
|
||||
|
||||
public class NewLiveActivity extends AppCompatActivity {
|
||||
private RtcEngine mRtcEngine;
|
||||
|
||||
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
|
||||
@Override
|
||||
// 监听频道内的远端用户,获取用户的 uid 信息
|
||||
public void onUserJoined(int uid, int elapsed) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 获取 uid 后,设置远端视频视图
|
||||
setupRemoteVideo(uid);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private void initializeAndJoinChannel() {
|
||||
try {
|
||||
// 创建 RtcEngineConfig 对象,并进行配置
|
||||
RtcEngineConfig config = new RtcEngineConfig();
|
||||
config.mContext = getBaseContext();
|
||||
config.mAppId = SWManager.shengwang_appId;
|
||||
config.mEventHandler = mRtcEventHandler;
|
||||
// 创建并初始化 RtcEngine
|
||||
mRtcEngine = RtcEngine.create(config);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Check the error.");
|
||||
}
|
||||
// 启用视频模块
|
||||
mRtcEngine.enableVideo();
|
||||
// 开启本地预览
|
||||
mRtcEngine.startPreview();
|
||||
|
||||
// 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象
|
||||
FrameLayout container = findViewById(R.id.local_video_view_container);
|
||||
SurfaceView surfaceView = new SurfaceView(getBaseContext());
|
||||
container.addView(surfaceView);
|
||||
// 将 SurfaceView 对象传入声网实时互动 SDK,设置本地视图
|
||||
mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT, 0));
|
||||
|
||||
// 创建 ChannelMediaOptions 对象,并进行配置
|
||||
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||
// 根据场景将用户角色设置为 BROADCASTER (主播) 或 AUDIENCE (观众)
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||
// 直播场景下,设置频道场景为 BROADCASTING (直播场景)
|
||||
options.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING;
|
||||
|
||||
// 使用临时 Token 加入频道,自行指定用户 ID 并确保其在频道内的唯一性
|
||||
mRtcEngine.joinChannel(SWManager.shengwang_token, SWManager.shengwang_channelName, 0, options);
|
||||
}
|
||||
|
||||
private void setupRemoteVideo(int uid) {
|
||||
FrameLayout container = findViewById(R.id.remote_video_view_container);
|
||||
SurfaceView surfaceView = new SurfaceView(getBaseContext());
|
||||
surfaceView.setZOrderMediaOverlay(true);
|
||||
container.addView(surfaceView);
|
||||
// 将 SurfaceView 对象传入声网实时互动 SDK,设置远端视图
|
||||
mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT, uid));
|
||||
}
|
||||
|
||||
private static final int PERMISSION_REQ_ID = 22;
|
||||
|
||||
// 获取体验实时音视频互动所需的录音、摄像头等权限
|
||||
private String[] getRequiredPermissions() {
|
||||
// 判断 targetSDKVersion 31 及以上时所需的权限
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
return new String[]{
|
||||
Manifest.permission.RECORD_AUDIO, // 录音权限
|
||||
Manifest.permission.CAMERA, // 摄像头权限
|
||||
Manifest.permission.READ_PHONE_STATE, // 读取电话状态权限
|
||||
Manifest.permission.BLUETOOTH_CONNECT // 蓝牙连接权限
|
||||
};
|
||||
} else {
|
||||
return new String[]{
|
||||
Manifest.permission.RECORD_AUDIO,
|
||||
Manifest.permission.CAMERA
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkPermissions() {
|
||||
for (String permission : getRequiredPermissions()) {
|
||||
int permissionCheck = ContextCompat.checkSelfPermission(this, permission);
|
||||
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.acticity_new_live);
|
||||
// 如果已经授权,则初始化 RtcEngine 并加入频道
|
||||
initializeAndJoinChannel();
|
||||
if (checkPermissions()) {
|
||||
initializeAndJoinChannel();
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, getRequiredPermissions(), PERMISSION_REQ_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
// 停止本地视频预览
|
||||
mRtcEngine.stopPreview();
|
||||
|
||||
// 离开频道
|
||||
mRtcEngine.leaveChannel();
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import com.yunbao.common.manager.RandomPkManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
@@ -683,9 +684,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
public void onLinkMicToPk(UserBean u) {
|
||||
EventBus.getDefault().post(new AnchorInfoEvent(false, u.getId(), u.getUserNiceName(), u.getAvatar()));
|
||||
Log.e("eve", u.getId() + "");
|
||||
L.eSw("主播接受了主播的PK邀請");
|
||||
/**
|
||||
* 加入副房间
|
||||
*
|
||||
* 前提必须已经 通过 {@link RCRTCEngine#joinRoom(String, RCRTCRoomType, IRCRTCResultDataCallback)} 或 {@link RCRTCEngine#joinRoom(String, IRCRTCResultDataCallback)} 加入了主房间
|
||||
*
|
||||
* @param roomId 房间 ID ,长度 64 个字符,可包含:`A-Z`、`a-z`、`0-9`、`+`、`=`、`-`、`_`
|
||||
@@ -693,7 +694,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
* @group 房间管理
|
||||
*/
|
||||
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
|
||||
RCRTCEngine.getInstance().joinOtherRoom(u.getId(), new IRCRTCResultDataCallback<RCRTCOtherRoom>() {
|
||||
/*RCRTCEngine.getInstance().joinOtherRoom(u.getId(), new IRCRTCResultDataCallback<RCRTCOtherRoom>() {
|
||||
@Override
|
||||
public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) {
|
||||
rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener);
|
||||
@@ -779,17 +780,18 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
public void onFailed(RTCErrorCode rtcErrorCode) {
|
||||
Log.i("ry", "11111加入其他房间失败 :" + rtcErrorCode.getReason());
|
||||
}
|
||||
});
|
||||
});*/
|
||||
LivePushRyViewHolder.btn_close.setVisibility(View.VISIBLE);
|
||||
LiveRyAnchorActivity.isDRPK = 1;
|
||||
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
||||
int mScreenWdith = util.getScreenWdith();
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
|
||||
/*LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
|
||||
params.weight = 1;
|
||||
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||
livePushRyViewHolder.camera.setLayoutParams(params);
|
||||
livePushRyViewHolder.mPreView1.setLayoutParams(params);
|
||||
livePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE);
|
||||
livePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE);*/
|
||||
livePushRyViewHolder.setAnPkRtc(u);//设置对方主播视图
|
||||
|
||||
final SocketSendBean msg1 = new SocketSendBean()
|
||||
.param("_method_", SOCKET_LINK_MIC_PK)
|
||||
@@ -801,7 +803,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
.param("pkname", u.getUserNiceName());
|
||||
msg1.create();
|
||||
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
|
||||
/*Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent);
|
||||
|
||||
@@ -821,7 +823,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
Log.e("tx", "发送失败" + errorCode.getMessage());
|
||||
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
}
|
||||
|
||||
@@ -837,7 +839,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
LivePushRyViewHolder.btn_close.setVisibility(View.VISIBLE);
|
||||
LiveRyAnchorActivity.isDRPK = 1;
|
||||
|
||||
JSONObject msg1 = new JSONObject();
|
||||
/*JSONObject msg1 = new JSONObject();
|
||||
msg1.put("uid", CommonAppConfig.getInstance().getUid());
|
||||
msg1.put("pkuid", CommonAppConfig.getInstance().getUid());
|
||||
msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatarThumb());
|
||||
@@ -847,9 +849,47 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
if (bean != null && bean.isRandomPk()) {
|
||||
msg1.put("random_pk", bean.isRandomPk() ? 1 : 0);
|
||||
msg1.put("is_ladders", bean.getRankPkImgUrl());
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------- */
|
||||
final SocketSendBean msg1 = new SocketSendBean()
|
||||
.param("_method_", SOCKET_LINK_MIC_PK)
|
||||
.param("action", 2) //回复PK申请 2
|
||||
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
|
||||
.param("pkuid", CommonAppConfig.getInstance().getUid())
|
||||
.param("uid", CommonAppConfig.getInstance().getUid())
|
||||
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
|
||||
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
||||
msg1.create();
|
||||
System.out.println("PK回执 = " + msg1.toString());
|
||||
IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, true, msg1.toString(), new IRCRTCResultCallback() {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain("g" + bean.getId(), conversationType, messageContent);
|
||||
|
||||
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(io.rong.imlib.model.Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(io.rong.imlib.model.Message message) {
|
||||
Log.e("tx", "发送成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
|
||||
Log.e("tx", "发送失败" + errorCode.getMessage());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: 2024/4/12 视图渲染
|
||||
livePushRyViewHolder.setAnPkRtc(bean);
|
||||
|
||||
|
||||
/*IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, true, msg1.toString(), new IRCRTCResultCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
RCRTCEngine.getInstance().joinOtherRoom(mApplyUid, new IRCRTCResultDataCallback<RCRTCOtherRoom>() {
|
||||
@@ -956,7 +996,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
public void onFailed(RTCErrorCode errorCode) {
|
||||
ToastUtil.show("接受失败");
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1374,7 +1374,7 @@ public class SocketRyClient {
|
||||
private void processAnchorLinkMicPk(JSONObject map) {
|
||||
int action = map.getIntValue("action");
|
||||
Log.i("Socket", "action = " + action + " json = " + map.toString());
|
||||
|
||||
L.eSw("处理主播与主播PK逻辑action = " + action + " json = " + map.toString());
|
||||
switch (action) {
|
||||
case 1://收到对方主播PK回调
|
||||
UserBean u = new UserBean();
|
||||
|
||||
@@ -11,6 +11,8 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.views.AbsViewHolder;
|
||||
@@ -30,7 +32,7 @@ public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushV
|
||||
protected ViewGroup mBigContainer;
|
||||
protected ViewGroup mSmallContainer;
|
||||
protected ViewGroup mLeftContainer;
|
||||
protected ViewGroup mRightContainer;
|
||||
protected FrameLayout mRightContainer;
|
||||
protected ViewGroup mPkContainer;
|
||||
public FrameLayout mPreView, mPreView1, cameraPreview3, dr1_preview, dr2_preview, dr3_preview, dr4_preview;
|
||||
public ImageView leave;
|
||||
@@ -59,7 +61,7 @@ public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushV
|
||||
mBigContainer = (ViewGroup) findViewById(R.id.big_container);
|
||||
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
|
||||
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
|
||||
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
|
||||
mRightContainer = (FrameLayout) findViewById(R.id.right_container);
|
||||
mPkContainer = (ViewGroup) findViewById(R.id.pk_container);
|
||||
mCameraFront = true;
|
||||
String mBeautySdkType = CommonAppConfig.getInstance().getBeautySdkType();
|
||||
|
||||
@@ -308,7 +308,6 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
}
|
||||
|
||||
private void setSelectClarity(int selectClarity) {
|
||||
|
||||
this.selectClarity = selectClarity;
|
||||
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
|
||||
switch (selectClarity) {
|
||||
@@ -330,7 +329,6 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
}
|
||||
SWManager.get().setDimensions(selectClarity);
|
||||
|
||||
|
||||
/*//設置開播分辨率
|
||||
RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||
int minRate = 200;
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
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.dialog.LiveFontSizeSettingDialog;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
@@ -100,6 +101,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
public StyledPlayerView mVideoView;
|
||||
|
||||
private FrameLayout playFrameLayout;
|
||||
private FrameLayout playFrameLayout1;
|
||||
|
||||
private View mLoading, mLoading2;
|
||||
private ImageView mCover;
|
||||
@@ -127,6 +129,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
RCRTCRoom rcrtcRoom;
|
||||
String purl, srcUrl;
|
||||
SWAuManager swAuManager;
|
||||
String liveUid;
|
||||
|
||||
public int getLandscape() {
|
||||
return landscape;
|
||||
@@ -137,9 +140,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
contexts = context;
|
||||
landscape = landscapes;
|
||||
Log.i("收收收", landscape + "");
|
||||
L.eSw("liveUid:" + liveUid);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_live_play_ksy;
|
||||
@@ -152,6 +155,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
Bus.getOn(this);
|
||||
mRoot = (ViewGroup) findViewById(R.id.root);
|
||||
playFrameLayout = (FrameLayout) findViewById(R.id.playView);
|
||||
playFrameLayout1 = (FrameLayout) findViewById(R.id.playView1);
|
||||
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
|
||||
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
|
||||
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
|
||||
@@ -174,15 +178,21 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
mPlayer.setMainView(mVideoView);
|
||||
mPlayer.setListener(new ExoPlayerListener());
|
||||
|
||||
debugView = new TextView(mContext);
|
||||
debugView.setBackgroundColor(Color.WHITE);
|
||||
}
|
||||
|
||||
public void initSwEngine(String liveUid) {
|
||||
this.liveUid = liveUid;
|
||||
swAuManager = SWAuManager.get();
|
||||
swAuManager.setAudienceContainer(playFrameLayout);
|
||||
swAuManager.initRtcEngine((Activity) mContext);
|
||||
swAuManager.setupRemoteVideo(11);
|
||||
swAuManager.joinRoom("9999", SWAuManager.shengwang_token, SWAuManager.shengwang_channelName);
|
||||
|
||||
debugView = new TextView(mContext);
|
||||
debugView.setBackgroundColor(Color.WHITE);
|
||||
swAuManager.setupRemoteVideo(Integer.parseInt(liveUid));
|
||||
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(liveUid));
|
||||
|
||||
//测试-模拟PK场景,加入第二个主播视图
|
||||
swAuManager.setPkContainer1(playFrameLayout1);
|
||||
swAuManager.joinExRoomEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(liveUid));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.IMRTCManager;
|
||||
import com.yunbao.common.manager.RandomPkManager;
|
||||
import com.yunbao.common.manager.SWAuManager;
|
||||
import com.yunbao.common.manager.SWManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
@@ -503,7 +504,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
HttpClient.getInstance().get("Livepk.endPK", "Livepk.endPK")
|
||||
.params("uid", CommonAppConfig.getInstance().getUid())
|
||||
.params("addtime", "1")
|
||||
@@ -772,23 +772,36 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
*/
|
||||
private void initRtcEngine() {
|
||||
swManager = SWManager.get();
|
||||
swManager.setAnchorContainer(mPreView);
|
||||
swManager.initRtcEngine((Activity) mContext, "11");
|
||||
swManager.setAnchorContainer((FrameLayout) mLeftContainer);
|
||||
swManager.initRtcEngine((Activity) mContext, CommonAppConfig.getInstance().getUid());
|
||||
swManager.setOnRtcEngineListener(new SWManager.onRtcEngineListener() {
|
||||
@Override
|
||||
public void onOpenSuccess(String channel, int uid) {
|
||||
//开播成功
|
||||
|
||||
L.eSw("开播成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setAnPkRtc(UserBean u) {
|
||||
if (swManager != null && u != null) {
|
||||
L.eSw("设置对方主播的视图setAnPkRtc" + u);
|
||||
|
||||
//将自己的渲染视图设置到 leftContainer
|
||||
//swManager.updateMyVideoView((FrameLayout) mLeftContainer,SWAuManager.getChannelName(CommonAppConfig.getInstance().getUid()));
|
||||
|
||||
//设置对方主播的渲染视图 设置到 rightContainer
|
||||
swManager.setPkContainer1(mRightContainer);
|
||||
swManager.joinExRoomEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,u.getId(), SWAuManager.getChannelName(u.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeToLeft() {
|
||||
if (mPreView != null) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mPreView.getLayoutParams();
|
||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mPreView.getLayoutParams();
|
||||
params.width = mPreView.getWidth() / 2;
|
||||
params.height = DpUtil.dp2px(250);
|
||||
params.height = DpUtil.dp2px(mPreView.getHeight());
|
||||
params.topMargin = DpUtil.dp2px(130);
|
||||
camera.setLayoutParams(params);
|
||||
}
|
||||
@@ -844,7 +857,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
ToastUtil.show(mContext.getString(R.string.live_open_flash));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -856,7 +868,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
public void startPush(String pushUrl) {
|
||||
//开播成功,创建频道
|
||||
if (swManager != null) {
|
||||
swManager.createRoom(SWManager.shengwang_token, SWManager.shengwang_channelName);
|
||||
swManager.createRoom(CommonAppConfig.SWToken, CommonAppConfig.getChannelName());
|
||||
}
|
||||
if (rcrtcLiveInfo != null) {
|
||||
rcrtcLiveInfo.addPublishStreamUrl(pushUrl, new IRCRTCResultDataCallback<String[]>() {
|
||||
|
||||
@@ -365,6 +365,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
liveHandler.removeCallbacks(loadTimeoutRunnableGone);
|
||||
if (mLivePlayViewHolder == null) {
|
||||
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
|
||||
mLivePlayViewHolder.initSwEngine(mLiveBean.getUid());
|
||||
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager());
|
||||
mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer);
|
||||
mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView());
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.NewLiveActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Start Video Call!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/local_video_view_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/remote_video_view_container"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="160dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@android:color/darker_gray"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,23 +2,39 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
android:animateLayoutChanges="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
|
||||
<com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
android:id="@+id/video_view"
|
||||
android:layout_width="match_parent"
|
||||
app:surface_type="texture_view"
|
||||
app:use_controller="false"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:layout_height="match_parent" />
|
||||
app:surface_type="texture_view"
|
||||
app:use_controller="false" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/playView"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="300dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/playView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/playView1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/leave"
|
||||
@@ -78,18 +94,19 @@
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="240dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="240dp"
|
||||
android:indeterminateBehavior="repeat"
|
||||
android:indeterminateDrawable="@drawable/anim_loading"
|
||||
android:indeterminateOnly="true"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading2"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="240dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="240dp"
|
||||
android:indeterminateBehavior="repeat"
|
||||
android:indeterminateDrawable="@drawable/anim_loading"
|
||||
android:indeterminateOnly="true"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -30,7 +29,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/camera_preview1"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -91,7 +89,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
@@ -161,17 +158,20 @@
|
||||
android:id="@+id/pk_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="270dp"
|
||||
android:background="@color/red"
|
||||
android:layout_marginTop="130dp">
|
||||
|
||||
<com.yunbao.live.custom.MyFrameLayout4
|
||||
android:id="@+id/left_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/green"
|
||||
android:layout_marginBottom="20dp" />
|
||||
|
||||
<com.yunbao.live.custom.MyFrameLayout4
|
||||
android:id="@+id/right_container"
|
||||
android:layout_width="0dp"
|
||||
android:background="@color/gray1"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginBottom="20dp" />
|
||||
@@ -195,7 +195,6 @@
|
||||
android:textSize="13sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
||||
<com.yunbao.live.custom.MyFrameLayout3
|
||||
android:id="@+id/small_container"
|
||||
android:layout_width="0dp"
|
||||
@@ -205,7 +204,6 @@
|
||||
android:layout_marginBottom="120dp"
|
||||
app:mfl3_ratio="0.25" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/leave"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user