Merge branch 'master' into tmp_mon
# Conflicts: # live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
@@ -1 +1 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.android.library'
|
||||
@@ -149,6 +149,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
private ImageView voicePress;
|
||||
private View titleLine;
|
||||
private boolean liveIndex = true;
|
||||
private boolean isPk = false;
|
||||
|
||||
@Override
|
||||
public <T extends View> T findViewById(@IdRes int id) {
|
||||
@@ -409,6 +410,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
return;
|
||||
}
|
||||
LiveGiftDialogFragment fragment = new LiveGiftDialogFragment();
|
||||
fragment.setPkStatus(isPk);
|
||||
fragment.setLiveGuardInfo(mLiveGuardInfo);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||||
@@ -423,6 +425,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
return;
|
||||
}
|
||||
LiveGiftDialogFragment fragment = new LiveGiftDialogFragment();
|
||||
fragment.setPkStatus(isPk);
|
||||
fragment.setLiveGuardInfo(mLiveGuardInfo);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||||
@@ -438,6 +441,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
}
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
LiveGiftDialogFragment fragment = new LiveGiftDialogFragment();
|
||||
fragment.setPkStatus(isPk);
|
||||
fragment.setLiveGuardInfo(mLiveGuardInfo);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||||
@@ -671,6 +675,17 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
verticalViewPager.setEnableScroll(IMLoginManager.get(mContext).isSlide());
|
||||
}
|
||||
|
||||
public void setPkStatus(boolean isPk) {
|
||||
this.isPk = isPk;
|
||||
if (manager != null) {
|
||||
manager.setPkStatus(isPk);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPkStatus() {
|
||||
return isPk;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLiveRoomChangeEvent(LiveRoomChangeEvent e) {
|
||||
if (verticalViewPager.ismEnableScroll()) {
|
||||
@@ -865,6 +880,13 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.NOTICE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeVideo() {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setBean(mLiveBean)
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void online() {
|
||||
|
||||
@@ -943,6 +965,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
return;
|
||||
}
|
||||
LiveGiftDialogFragment liveGiftDialogFragment = new LiveGiftDialogFragment();
|
||||
liveGiftDialogFragment.setPkStatus(isPk);
|
||||
liveGiftDialogFragment.setLiveGuardInfo(mLiveGuardInfo);
|
||||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||||
bundle.putString(Constants.LIVE_STREAM, mStream);
|
||||
@@ -1163,6 +1186,9 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
case LUCKY_ANGEL:
|
||||
manager.luckyAngel(event.getMsgModel());
|
||||
break;
|
||||
case LUCKY_100_CHECK:
|
||||
manager.lucky100(event.getMsgModel());
|
||||
break;
|
||||
case LINK_MIC:
|
||||
if (!StringUtil.isEmpty(((LinkMicUserBean) event.getObject()).getUid())) {
|
||||
mMicQueueList.put(((LinkMicUserBean) event.getObject()).getUid(), (LinkMicUserBean) event.getObject());
|
||||
@@ -1230,7 +1256,11 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case LEAVE_PK_SCORE:
|
||||
if (manager != null) {
|
||||
manager.upDataPkScore(event.getPkScores(), event.getTime());
|
||||
}
|
||||
break;
|
||||
case PK_TIME_COUNT:
|
||||
if (manager != null) {
|
||||
manager.endDRGif();
|
||||
|
||||
@@ -5,8 +5,6 @@ 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_LIVE_DRPK;
|
||||
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK_RANDOM;
|
||||
import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView;
|
||||
import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
|
||||
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_dr_pk_nub;
|
||||
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk;
|
||||
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk_view;
|
||||
@@ -17,13 +15,13 @@ import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -31,17 +29,22 @@ import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.tencent.trtc.TRTCCloudDef;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.AiAutomaticSpeechModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LinkMicUserBean;
|
||||
import com.yunbao.common.bean.LiveAiRobotBean;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.LiveUserGiftBean;
|
||||
import com.yunbao.common.bean.MicUserBean;
|
||||
@@ -52,6 +55,7 @@ import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
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;
|
||||
@@ -59,11 +63,9 @@ import com.yunbao.common.utils.BitmapUtil;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DateFormatUtil;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LogUtil;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
@@ -99,14 +101,20 @@ import com.yunbao.live.views.LivePushRyViewHolder;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
import com.yunbao.live.views.LiveRyAnchorViewHolder;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
||||
import cn.rongcloud.rtc.api.callback.IRCRTCStatusReportListener;
|
||||
import cn.rongcloud.rtc.api.report.StatusBean;
|
||||
import cn.rongcloud.rtc.api.report.StatusReport;
|
||||
import cn.rongcloud.rtc.base.RCRTCRect;
|
||||
import cn.rongcloud.rtc.base.RTCErrorCode;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
@@ -155,6 +163,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
public static int backIndex = 0;//0=未判断,1=已判断
|
||||
private FaceManager manager;
|
||||
private ImageView leave_img;
|
||||
|
||||
private final RandomPkManager.OnRandomPkTimer onRandomPkTimer = new RandomPkManager.OnRandomPkTimer() {
|
||||
@Override
|
||||
public void onTimer(String time) {
|
||||
@@ -199,6 +208,27 @@ 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);
|
||||
@@ -284,6 +314,52 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
switch (functionID) {
|
||||
case Constants.LIVE_ROBOT:
|
||||
new XPopup.Builder(mContext)
|
||||
.setPopupCallback(new XPopupCallback() {
|
||||
@Override
|
||||
public void onCreated(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(BasePopupView popupView) {
|
||||
EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UPDATA_ROBOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDismiss(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(BasePopupView popupView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickOutside(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
})
|
||||
.asCustom(new LiveRobotSettingCustomPopup(mContext))
|
||||
.show();
|
||||
break;
|
||||
@@ -326,7 +402,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
|
||||
if (code == 0) {
|
||||
btn_start_dr_pk.setVisibility(View.VISIBLE);
|
||||
dr_pk_view.setVisibility(View.VISIBLE);
|
||||
// dr_pk_view.setVisibility(View.VISIBLE);
|
||||
final SocketSendBean msg1 = new SocketSendBean()
|
||||
.param("_method_", SOCKET_LIVE_DRPK)
|
||||
.param("action", 9)
|
||||
@@ -346,18 +422,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
isDRPK = 1;
|
||||
|
||||
btn_start_dr_pk_view.setVisibility(View.VISIBLE);
|
||||
dr_pk_view.setVisibility(View.VISIBLE);
|
||||
|
||||
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
||||
int mScreenWdith = util.getScreenWdith();
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
|
||||
params.weight = 1;
|
||||
params.topMargin = DpUtil.dp2px(123);
|
||||
dr_pk_view.setLayoutParams(params);
|
||||
mPreView.setLayoutParams(params);
|
||||
|
||||
mLiveRyLinkMicPkPresenter.setDRInitiator(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -674,6 +740,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
* @param data createRoom返回的数据
|
||||
*/
|
||||
public void startLiveSuccess(String data, int liveType, int liveTypeVal) {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((" + data);
|
||||
mLiveType = liveType;
|
||||
mLiveTypeVal = liveTypeVal;
|
||||
//处理createRoom返回的数据
|
||||
@@ -774,6 +841,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
if (CommonAppConfig.GAME_ENABLE) {
|
||||
mGameList = JSON.parseArray(obj.getString("game_switch"), Integer.class);
|
||||
}
|
||||
getAiRobotStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -786,6 +854,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
PKing = false;
|
||||
isDRPK = 0;
|
||||
endLive();
|
||||
RandomPkManager.getInstance().release();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -861,6 +930,10 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
LiveHttpUtil.stopLive(mStream, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (robotRunnable != null) {
|
||||
robotHandler.removeCallbacks(robotRunnable);
|
||||
robotRunnable = null;
|
||||
}
|
||||
if (code == 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
JSONObject datas = obj.getJSONObject("data");
|
||||
@@ -1490,7 +1563,11 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
mLiveRyLinkMicPkPresenter.leaveDRRoom();
|
||||
}
|
||||
break;
|
||||
|
||||
case LEAVE_PK_SCORE:
|
||||
if (mLiveRyLinkMicPkPresenter != null) {
|
||||
mLiveRyLinkMicPkPresenter.upDataPkScore(event.getPkScores(), event.getUid(), event.getTime());
|
||||
}
|
||||
break;
|
||||
case PK_TIME_COUNT:
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.endDRGif();
|
||||
@@ -1501,6 +1578,18 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
mLivePushViewHolder.changeToBig();
|
||||
}
|
||||
break;
|
||||
case AI_AUTOMATIC_SPEECH:
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.aiAutomaticSpeech((event.getAiAutomaticSpeechModel()));
|
||||
}
|
||||
break;
|
||||
case UPDATA_ROBOT:
|
||||
getAiRobotStatus();
|
||||
break;
|
||||
//主播强制下播
|
||||
case LIVE_END:
|
||||
endLive();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1527,4 +1616,118 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机器人配置;取得求关注时间间隔
|
||||
*/
|
||||
private long robotTime = 0;
|
||||
|
||||
private void getAiRobotStatus() {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((");
|
||||
LiveNetManager.get(mContext)
|
||||
.getAiRobotStatus(new com.yunbao.common.http.base.HttpCallback<LiveAiRobotBean>() {
|
||||
@Override
|
||||
public void onSuccess(LiveAiRobotBean data) {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((" + data.toString());
|
||||
if (data.getStatus() == 1) {
|
||||
if (robotRunnable != null) {
|
||||
robotHandler.removeCallbacks(robotRunnable);
|
||||
robotRunnable = null;
|
||||
}
|
||||
robotRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data.getName())" + data.getName());
|
||||
String robotName = data.getName();
|
||||
//发送消息
|
||||
LiveNetManager.get(mContext)
|
||||
.getAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW,
|
||||
new com.yunbao.common.http.base.HttpCallback<List<LiveAiRobotBean.Message>>() {
|
||||
@Override
|
||||
public void onSuccess(List<LiveAiRobotBean.Message> messageList) {
|
||||
Random random = new Random();
|
||||
int randNumber = random.nextInt(messageList.size()) - 1;
|
||||
if (randNumber < 0) {
|
||||
randNumber = 0;
|
||||
}
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data.randNumber())" + randNumber);
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data)" + messageList.toString());
|
||||
sendRobotMessage(robotName, messageList.get(randNumber).getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data.error())" + error);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
robotTime = data.getTime() * 60 * 1000;
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((robotTime)" + robotTime);
|
||||
robotHandler.postDelayed(robotRunnable, robotTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//机器人求关注轮询器
|
||||
private Handler robotHandler = new Handler();
|
||||
private Runnable robotRunnable = null;
|
||||
|
||||
/**
|
||||
* '{"msg":
|
||||
* [{"_method_":"aiAutomaticSpeech",
|
||||
* "ct":{"name_color":"#f19ec2","ai_name":"'+_this.robotInfo.ai_name+'",
|
||||
* "content":"'+content+'","user_name":"",
|
||||
* "icon":"https://downs.yaoulive.com/xzs_tab.png",
|
||||
* "system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"},
|
||||
* "msgtype":"10"}],"retcode":"000000","retmsg":"OK"}'
|
||||
*/
|
||||
private void sendRobotMessage(String name, String content) {
|
||||
Log.e("随机打招呼", name + "==========00000000000000++++" + content);
|
||||
AiAutomaticSpeechModel aiAutomaticSpeechModel = new AiAutomaticSpeechModel();
|
||||
aiAutomaticSpeechModel.setAiName(name)
|
||||
.setIcon("https://downs.yaoulive.com/xzs_tab.png")
|
||||
.setNameColor("#f19ec2")
|
||||
.setSystemBubble("https://downs.yaoulive.com/xzs_qipao.9.png")
|
||||
.setUserName("")
|
||||
.setContent(content);
|
||||
SocketSendBean msg =
|
||||
new SocketSendBean()
|
||||
.param("_method_", "aiAutomaticSpeechNew")
|
||||
.param("msgtype", "10")
|
||||
.param("ct", GsonUtils.toJson(aiAutomaticSpeechModel, AiAutomaticSpeechModel.class));
|
||||
msg.create();
|
||||
String targetId = "g" + mLiveUid;
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
|
||||
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
|
||||
Message message = Message.obtain(targetId, conversationType, messageContent);
|
||||
|
||||
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
if (SocketRyClient.mSocketHandler != null) {
|
||||
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
Log.e("tx", "aaa" + errorCode.toString());
|
||||
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
|
||||
}
|
||||
});
|
||||
robotHandler.postDelayed(robotRunnable, robotTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.live.dialog.LiveBeautyDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
@@ -213,7 +213,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
|
||||
return;
|
||||
}
|
||||
String title = mEditTitle.getText().toString().trim();
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, null, new HttpCallback() {
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, null,0, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, final String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
|
||||
@@ -115,7 +115,7 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
|
||||
}
|
||||
if (freePkNum == 0 && mDrPkNum == -1) {
|
||||
ToastUtil.show(R.string.free_pk_num_null);
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
|
||||
LiveHttpUtil.getMicList(LiveRyAnchorActivity.mLiveUid, 0, new com.yunbao.common.http.HttpCallback() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import static com.yunbao.live.bean.LiveChatBean.AI_AUTOMATIC_SPEECH;
|
||||
import static com.yunbao.live.bean.LiveChatBean.LUCKY_100_CHECK;
|
||||
import static com.yunbao.live.bean.LiveChatBean.LUCKY_ANGEL;
|
||||
import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
|
||||
import static com.yunbao.live.bean.LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY;
|
||||
@@ -16,6 +17,8 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -47,7 +50,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/10.
|
||||
@@ -68,6 +70,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
private int mRecyclerViewScrolledDy;
|
||||
|
||||
private int mPosition;
|
||||
private boolean isBottom = false;
|
||||
|
||||
public LiveChatAdapter(Context context) {
|
||||
mContext = context;
|
||||
@@ -128,8 +131,24 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
if (isSlideToBottom(recyclerView) || dy == 0) return;
|
||||
if (isBottom && dy >= 0) return;
|
||||
Log.i(TAG, "onScrolled: " + dy);
|
||||
mRecyclerViewScrolledDy = dy;
|
||||
isBottom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == 0 && isSlideToBottom(recyclerView)) {
|
||||
// Log.i(TAG, "onScrollStateChanged: 到底部了");
|
||||
mRecyclerViewScrolledDy = 0;
|
||||
scrollToBottom();
|
||||
isBottom = true;
|
||||
} else if (newState == 0) {
|
||||
// Log.i(TAG, "onScrollStateChanged: 不是底部");
|
||||
isBottom = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -360,7 +379,15 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
new LiveTextRender().luckyAngel(mContext, mTextView, bean.getMsgModel());
|
||||
}
|
||||
|
||||
} else {
|
||||
}else if(bean.getType() == LUCKY_100_CHECK){
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
|
||||
bean.setId(bean.getMsgModel().getUserId());
|
||||
itemView.setTag(bean);
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1);
|
||||
new LiveTextRender().lucky100(mContext, mTextView, bean.getMsgModel());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
@@ -375,18 +402,21 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
|
||||
new LiveTextRender().render(mContext, mTextView, bean);
|
||||
}
|
||||
Animation animation = AnimationUtils.loadAnimation(itemView.getContext(),R.anim.live_chat_msg_in);
|
||||
itemView.startAnimation(animation);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void insertItem(LiveChatBean bean) {
|
||||
public synchronized void insertItem(LiveChatBean bean) {
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
// Log.i(TAG, "insertItem: " + bean.getContent());
|
||||
// Log.i(TAG, "insertItem: " + bean.getContent()+" size = "+(mList.size()+1));
|
||||
int size = mList.size();
|
||||
//设置最大展示99条消息
|
||||
if (size == 100) {
|
||||
if (size >= 100 && (isBottom || mRecyclerViewScrolledDy == 0)) {
|
||||
|
||||
mList.subList(0, 50).clear();
|
||||
notifyItemRangeRemoved(0, 50);
|
||||
}
|
||||
@@ -396,8 +426,8 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
} else {
|
||||
notifyItemInserted(getItemCount());
|
||||
}
|
||||
size = mList.size();
|
||||
if (isSlideToBottom(mRecyclerView) || mRecyclerViewScrolledDy == 0) {
|
||||
// size = mList.size();
|
||||
if (isBottom || mRecyclerViewScrolledDy == 0) {
|
||||
scrollToBottom();
|
||||
} else {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
@@ -413,6 +443,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void scrollToBottom(final RecyclerView recyclerView) {
|
||||
// scroll to last item to get the view of last item
|
||||
final LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
@@ -445,16 +476,19 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mList.remove(bean.getHeart());
|
||||
notifyItemRemoved(bean.getHeart());
|
||||
notifyItemRangeChanged(bean.getHeart(), getItemCount());
|
||||
|
||||
}
|
||||
|
||||
public void scrollToBottom() {
|
||||
mRecyclerViewScrolledDy = 0;
|
||||
if (mList.size() > 0) {
|
||||
mRecyclerView.smoothScrollToPosition(getItemCount() - 1);
|
||||
}
|
||||
mRecyclerViewScrolledDy = 0;
|
||||
}
|
||||
|
||||
public void scrollToAt() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class LiveChatRecyclerViewLayoutManager extends LinearLayoutManager {
|
||||
private static final float MILLISECONDS_PER_INCH = 200f;
|
||||
private static final float MILLISECONDS_PER_INCH = 150f;
|
||||
public LiveChatRecyclerViewLayoutManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -22,6 +22,7 @@ public class LiveChatBean {
|
||||
public static final int AI_AUTOMATIC_SPEECH = 101;
|
||||
public static final int STAR_CHALLENGE_UPGRADE_NOTIFY = 105;
|
||||
public static final int LUCKY_ANGEL = 106;//幸运天使
|
||||
public static final int LUCKY_100_CHECK = 107;//幸运天使
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.yunbao.live.bean;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/8.
|
||||
* 直播房间类型
|
||||
*/
|
||||
|
||||
public class LiveRoomTypeBean {
|
||||
|
||||
private int mId;
|
||||
private String mName;
|
||||
private int mCheckedIcon;
|
||||
private int mUnCheckedIcon;
|
||||
private boolean mChecked;
|
||||
|
||||
public LiveRoomTypeBean() {
|
||||
}
|
||||
|
||||
public LiveRoomTypeBean(int id, String name) {
|
||||
mId = id;
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public LiveRoomTypeBean(int id, String name, int checkedIcon, int unCheckedIcon) {
|
||||
mId = id;
|
||||
mName = name;
|
||||
mCheckedIcon = checkedIcon;
|
||||
mUnCheckedIcon = unCheckedIcon;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
mId = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public int getCheckedIcon() {
|
||||
return mCheckedIcon;
|
||||
}
|
||||
|
||||
public void setCheckedIcon(int checkedIcon) {
|
||||
mCheckedIcon = checkedIcon;
|
||||
}
|
||||
|
||||
public int getUnCheckedIcon() {
|
||||
return mUnCheckedIcon;
|
||||
}
|
||||
|
||||
public void setUnCheckedIcon(int unCheckedIcon) {
|
||||
mUnCheckedIcon = unCheckedIcon;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
mChecked = checked;
|
||||
}
|
||||
|
||||
public static List<LiveRoomTypeBean> getLiveTypeList(String[][] liveTypes) {
|
||||
List<LiveRoomTypeBean> list = new ArrayList<>();
|
||||
if (liveTypes != null) {
|
||||
for (String[] arr : liveTypes) {
|
||||
LiveRoomTypeBean bean = new LiveRoomTypeBean(Integer.parseInt(arr[0]), arr[1]);
|
||||
switch (bean.getId()) {
|
||||
case Constants.LIVE_TYPE_NORMAL:
|
||||
bean.setCheckedIcon(R.mipmap.icon_live_type_normal_1);
|
||||
bean.setUnCheckedIcon(R.mipmap.icon_live_type_normal_2);
|
||||
break;
|
||||
case Constants.LIVE_TYPE_PWD:
|
||||
bean.setCheckedIcon(R.mipmap.icon_live_type_pwd_1);
|
||||
bean.setUnCheckedIcon(R.mipmap.icon_live_type_pwd_2);
|
||||
break;
|
||||
case Constants.LIVE_TYPE_PAY:
|
||||
bean.setCheckedIcon(R.mipmap.icon_live_type_pay_1);
|
||||
bean.setUnCheckedIcon(R.mipmap.icon_live_type_pay_2);
|
||||
break;
|
||||
case Constants.LIVE_TYPE_TIME:
|
||||
bean.setCheckedIcon(R.mipmap.icon_live_type_time_1);
|
||||
bean.setUnCheckedIcon(R.mipmap.icon_live_type_time_2);
|
||||
break;
|
||||
}
|
||||
list.add(bean);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
private TextView mVipGoldTitle;
|
||||
private TextView mVipGoldDesc;
|
||||
private TextView mGiftPackage;
|
||||
private boolean isPk;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -154,6 +155,10 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
mLiveGuardInfo = liveGuardInfo;
|
||||
}
|
||||
|
||||
public void setPkStatus(boolean pk) {
|
||||
isPk = pk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
@@ -203,7 +208,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (mRadioGroup != null) {
|
||||
if (mRadioGroup != null && mRadioGroup.getChildAt(position)!=null) {
|
||||
((RadioButton) mRadioGroup.getChildAt(position)).setChecked(true);
|
||||
}
|
||||
}
|
||||
@@ -276,6 +281,9 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
}
|
||||
loadGiftListData();
|
||||
loadUserVip();
|
||||
if (isPk) {
|
||||
mVipGold.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.yunbao.live.dialog;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActionBar;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@@ -37,6 +38,7 @@ import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.bean.HotBean;
|
||||
import com.yunbao.live.custom.TopGradual;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@@ -205,7 +207,17 @@ public class LiveGiveHotDialogFragment extends AbsDialogFragment {
|
||||
viewHolder.sex.setImageResource(CommonIconUtil.getSexIcon(mDatas.get(position).getSex()));
|
||||
LevelBean levelBean = CommonAppConfig.getInstance().getLevel(mDatas.get(position).getLevel());
|
||||
if (levelBean != null) {
|
||||
ImgLoader.display(mContext, levelBean.getThumb(), viewHolder.level);
|
||||
new LiveTextRender().getLevelImage(mContext, levelBean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ImgLoader.display2(mContext, drawable, viewHolder.level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
String hotStr = mDatas.get(position).getHot_score().substring(0, mDatas.get(position).getHot_score().length() - 3);
|
||||
viewHolder.tv_hot_number.setText(hotStr + "k");
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveReadyClassAdapter;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -217,6 +217,7 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O
|
||||
@Override
|
||||
public void onSuccess(PrankHttpTurntableBean data) {
|
||||
setDate(data);
|
||||
mCoinTextView.setText(data.getCoin()+"");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveRoomTypeAdapter;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/8.
|
||||
|
||||
@@ -31,6 +31,46 @@ public class LiveAudienceEvent extends BaseModel {
|
||||
private int time;
|
||||
private CustomFullServiceNotifyEvent customFullServiceNotifyEvent;
|
||||
private LivePKUserListBean livePKUserListBean;
|
||||
private String votes;
|
||||
private String length;
|
||||
private int nums;
|
||||
private String uname;
|
||||
|
||||
public String getVotes() {
|
||||
return votes;
|
||||
}
|
||||
|
||||
public LiveAudienceEvent setVotes(String votes) {
|
||||
this.votes = votes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public LiveAudienceEvent setLength(String length) {
|
||||
this.length = length;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getNums() {
|
||||
return nums;
|
||||
}
|
||||
|
||||
public LiveAudienceEvent setNums(int nums) {
|
||||
this.nums = nums;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUname() {
|
||||
return uname;
|
||||
}
|
||||
|
||||
public LiveAudienceEvent setUname(String uname) {
|
||||
this.uname = uname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LivePKUserListBean getLivePKUserListBean() {
|
||||
return livePKUserListBean;
|
||||
@@ -255,7 +295,11 @@ public class LiveAudienceEvent extends BaseModel {
|
||||
DISCONNEXT_PK_TIME(50, "单人Pk结束"),
|
||||
UP_PK_TWO(51, "PK头像信息"),
|
||||
CUSTOM_FULL_SERVICE_NOTIFY(51, "全服通知"),
|
||||
CHANGE_VIEW(52, "更改连胜位置");
|
||||
CHANGE_VIEW(52, "更改连胜位置"),
|
||||
UPDATA_ROBOT(53, "更新机器人消息"),
|
||||
LIVE_VIDEO(54, "画质选择"),
|
||||
LUCKY_100_CHECK(55, "幸运百分百"),
|
||||
LIVE_END(56, "主播下播");
|
||||
|
||||
private int type;
|
||||
private String name;
|
||||
|
||||
@@ -47,10 +47,11 @@ public class LiveHttpUtil {
|
||||
|
||||
/**
|
||||
* 获取直播用户日榜/周榜
|
||||
* @param liveUid 主播uid
|
||||
*
|
||||
* @param liveUid 主播uid
|
||||
* @param callback 回调
|
||||
*/
|
||||
public static void getUserRankList(String liveUid,HttpCallback callback){
|
||||
public static void getUserRankList(String liveUid, HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Contribute.index", LiveHttpConsts.GET_USER_LIST)
|
||||
.params("uid", liveUid)
|
||||
.execute(callback);
|
||||
@@ -685,7 +686,7 @@ public class LiveHttpUtil {
|
||||
* @param file 封面图片文件
|
||||
* @param callback
|
||||
*/
|
||||
public static void newcreateRoom(String title, int liveClassId, int type, int typeVal, File file, HttpCallback callback) {
|
||||
public static void newcreateRoom(String title, int liveClassId, int type, int typeVal, File file, int clarityType, HttpCallback callback) {
|
||||
|
||||
PostRequest<JsonBean> request = HttpClient.getInstance().post("Live.createRoom2", LiveHttpConsts.CREATE_ROOM)
|
||||
.params("title", title)
|
||||
@@ -693,7 +694,8 @@ public class LiveHttpUtil {
|
||||
.params("type", type)
|
||||
.params("landscape", "2")
|
||||
.params("class_type", "0")
|
||||
.params("type_val", typeVal);
|
||||
.params("type_val", typeVal)
|
||||
.params("clarityType", clarityType);
|
||||
if (file != null) {
|
||||
request.params("file", file);
|
||||
}
|
||||
@@ -902,16 +904,17 @@ public class LiveHttpUtil {
|
||||
/**
|
||||
* 获取用户贵族喇叭的数量
|
||||
*/
|
||||
public static void nobleUseTrumpet(String trumpet_msg,String anchor_id,HttpCallback callback) {
|
||||
public static void nobleUseTrumpet(String trumpet_msg, String anchor_id, HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Noble.nobleUseTrumpet", "nobleUseTrumpet")
|
||||
.params("", trumpet_msg)
|
||||
.params("", anchor_id)
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户贵族喇叭的数量
|
||||
*/
|
||||
public static void getStarChallengeStatus(String liveUid,HttpCallback callback) {
|
||||
public static void getStarChallengeStatus(String liveUid, HttpCallback callback) {
|
||||
HttpClient.getInstance().get("StarChallenge.getStarChallengeStatus", "StarChallengeStatus")
|
||||
.params("liveUid", liveUid)
|
||||
.execute(callback);
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.GiftCacheUtil;
|
||||
import com.yunbao.common.utils.HtmlTagHandler;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
@@ -55,6 +56,7 @@ import com.yunbao.live.bean.LiveGiftPrizePoolWinBean;
|
||||
import com.yunbao.live.bean.LiveLuckGiftWinBean;
|
||||
import com.yunbao.live.bean.LiveReceiveGiftBean;
|
||||
import com.yunbao.live.custom.FrameImageView;
|
||||
import com.yunbao.live.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.utils.AllMsgTextRender;
|
||||
import com.yunbao.live.utils.LiveIconUtil;
|
||||
@@ -63,6 +65,8 @@ import com.yunbao.live.views.LiveGiftPrizePoolViewHolder;
|
||||
import com.yunbao.live.views.LiveGiftViewHolder;
|
||||
import com.yunbao.live.views.LiveTitleAnimViewHolder;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -378,7 +382,14 @@ public class LiveGiftAnimPresenter {
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
if (MicStatusManager.getInstance().isMic(liveUid)) {
|
||||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||||
return;
|
||||
}
|
||||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)).setLiveEnd(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.yunbao.live.socket;
|
||||
import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
|
||||
import static com.blankj.utilcode.util.ViewUtils.runOnUiThread;
|
||||
import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
|
||||
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom;
|
||||
import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
|
||||
import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom;
|
||||
import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
|
||||
|
||||
@@ -281,42 +279,58 @@ public class SocketRyClient {
|
||||
}
|
||||
//收到对方同意多人PK邀请
|
||||
else if (action3 == 2) {
|
||||
UserBean u = new UserBean();
|
||||
// u.setUserNiceName(map.getString("uname"));
|
||||
u.setId(map.getString("uid"));
|
||||
mListener.onLinkDRMicPkApplyOk(u);
|
||||
} else if (action3 == 6) {
|
||||
// UserBean u = new UserBean();
|
||||
//// u.setUserNiceName(map.getString("uname"));
|
||||
// u.setId(map.getString("uid"));
|
||||
// mListener.onLinkDRMicPkApplyOk(u);
|
||||
} else if (action3 == 6) {//开始Pk
|
||||
if (LiveRoomViewHolder.mHandler != null) {
|
||||
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time"));
|
||||
// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time"));
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE)
|
||||
.setPkScores(map.getJSONArray("userlist"))
|
||||
.setUid(mLiveUid)
|
||||
.setTime(map.getIntValue("drpk_time")));
|
||||
if (livePushRyViewHolder == null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
|
||||
);
|
||||
}
|
||||
|
||||
} else if (action3 == 5) {
|
||||
// EventBus.getDefault().post(new LiveAudienceEvent()
|
||||
// .setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
|
||||
// endDRGif();
|
||||
LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE);
|
||||
if (LiveRyAnchorActivity.mLiveAnchorViewHolder != null) {
|
||||
dr_pk_view.setVisibility(View.GONE);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = 0;
|
||||
LivePushRyViewHolder.mPreView.setLayoutParams(params);
|
||||
leaveDRRoom();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM));
|
||||
isDRPK = 0;
|
||||
} else {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW)
|
||||
);
|
||||
|
||||
}
|
||||
//創建了多人房間
|
||||
} else if (action3 == 3) {
|
||||
if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
/* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
}
|
||||
}*/
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
|
||||
);
|
||||
isDRPK = 1;
|
||||
} else if (action3 == 10) {
|
||||
if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,6 +377,13 @@ public class SocketRyClient {
|
||||
} else if (action == 19) {
|
||||
mListener.onAnchorInvalid();
|
||||
}
|
||||
//主播强制下播
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_END)
|
||||
.setVotes(map.getString("votes"))
|
||||
.setLength(map.getString("length"))
|
||||
.setNums(map.getIntValue("nums"))
|
||||
.setUname(map.getString("uname")));
|
||||
break;
|
||||
case Constants.SOCKET_CHANGE_LIVE://主播切换计时收费类型
|
||||
mListener.onChangeTimeCharge(map.getIntValue("type_val"));
|
||||
@@ -529,6 +550,7 @@ public class SocketRyClient {
|
||||
}
|
||||
break;
|
||||
case Constants.AI_AUTOMATIC_SPEECH:
|
||||
case Constants.AI_AUTOMATIC_SPEECH_LIVE:
|
||||
//{"name_color":"#f19ec2","ai_name":"助手小小P","content":"@1 ","user_name":"1","icon":"https://downs.yaoulive.com/xzs_tab.png","system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"}
|
||||
AiAutomaticSpeechModel aiAutomaticSpeechModel = GsonUtils.fromJson(map.getString("ct"), AiAutomaticSpeechModel.class);
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
@@ -550,6 +572,11 @@ public class SocketRyClient {
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LUCKY_ANGEL)
|
||||
.setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
|
||||
break;
|
||||
case Constants.Lucky100Check:
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LUCKY_100_CHECK)
|
||||
.setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
|
||||
break;
|
||||
case Constants.PK_RANK_UPDATE:
|
||||
Log.i("PK排位", map.toString());
|
||||
JSONObject item = map.getJSONObject("ct");
|
||||
@@ -911,7 +938,12 @@ public class SocketRyClient {
|
||||
mListener.onSendGift(receiveGiftBean);
|
||||
}
|
||||
if (map.getIntValue("drpk_status") == 1) {
|
||||
LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE)
|
||||
.setPkScores(map.getJSONArray("userlist"))
|
||||
.setUid(mLiveUid)
|
||||
.setTime(0));
|
||||
// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1061,16 +1093,8 @@ public class SocketRyClient {
|
||||
break;
|
||||
case 5://PK时候断开连麦的回调
|
||||
if (rtcRoom != null) {
|
||||
if (LivePushRyViewHolder.mPreView1 != null) {
|
||||
LivePushRyViewHolder.mPreView1.removeAllViews();
|
||||
LivePushRyViewHolder.mPreView1.setVisibility(View.GONE);
|
||||
isDRPK = 0;
|
||||
leaveDRRoom();
|
||||
}
|
||||
LivePushRyViewHolder.btn_close.setVisibility(View.GONE);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = 0;
|
||||
LivePushRyViewHolder.mPreView.setLayoutParams(params);
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.DISCONNEXT_PK_TIME));
|
||||
//断开连麦
|
||||
HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout")
|
||||
.execute(new HttpCallback() {
|
||||
|
||||
@@ -68,10 +68,13 @@ public class AllMsgTextRender {
|
||||
ImgLoader.displayDrawable(context, url, new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
builder = createPrefix(drawable, builder);
|
||||
builder = renderMsg(color2, builder, text);
|
||||
textView.setText(builder);
|
||||
giftAnimPresenter.setCountDownTimerEnd(intoIndex);
|
||||
if (builder!=null&&!builder.toString().contains(text)){
|
||||
builder = createPrefix(drawable, builder);
|
||||
builder = renderMsg(color2, builder, text);
|
||||
textView.setText(builder);
|
||||
giftAnimPresenter.setCountDownTimerEnd(intoIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,408 @@
|
||||
package com.yunbao.live.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.DefaultLoadControl;
|
||||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView;
|
||||
import com.google.android.exoplayer2.video.VideoSize;
|
||||
|
||||
/**
|
||||
* 直播间播放器管理器
|
||||
* 通过预加载子播放器来实现无缝切换分辨率功能
|
||||
*/
|
||||
public class LiveExoPlayerManager {
|
||||
private final int MODEL_PLAY1 = 0;//当前主播放器
|
||||
private final int MODEL_PLAY2 = 1;//当前子播放器
|
||||
private ExoPlayer player1;
|
||||
private ExoPlayer player2;
|
||||
private StyledPlayerView mainView;//渲染视图
|
||||
private int status = MODEL_PLAY1;
|
||||
private Player.Listener listener;
|
||||
private boolean isSwitchUrl = false;//是否为主动切换播放器
|
||||
private final String TAG = "播放器";
|
||||
private int playBufferIndex = 0;//卡顿计数器
|
||||
private final Handler handler;
|
||||
private static double log_buffer_time = 0, log_buffer_max_time;
|
||||
private String url = "";
|
||||
|
||||
public LiveExoPlayerManager(Context mContext) {
|
||||
DefaultLoadControl control = new DefaultLoadControl.Builder()
|
||||
.setPrioritizeTimeOverSizeThresholds(false)
|
||||
.setBackBuffer(10_000, true)
|
||||
.setBufferDurationsMs(500,
|
||||
5_000,
|
||||
150,
|
||||
200)
|
||||
.build();
|
||||
player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
||||
player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
||||
player1.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
|
||||
player2.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
|
||||
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
setListener();
|
||||
setAnalyticsListener();
|
||||
}
|
||||
|
||||
|
||||
public void setListener(Player.Listener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setMainView(StyledPlayerView mainView) {
|
||||
this.mainView = mainView;
|
||||
this.mainView.setKeepContentOnPlayerReset(true);
|
||||
}
|
||||
|
||||
public void setViewResizeMode(boolean isPhone) {
|
||||
Log.i(TAG, "setViewResizeMode: " + isPhone);
|
||||
mainView.setResizeMode(isPhone ? AspectRatioFrameLayout.RESIZE_MODE_ZOOM : AspectRatioFrameLayout.RESIZE_MODE_FIT);
|
||||
mainView.requestLayout();
|
||||
}
|
||||
|
||||
public boolean isViewResizeModeToPhone() {
|
||||
return mainView.getResizeMode() == AspectRatioFrameLayout.RESIZE_MODE_ZOOM;
|
||||
}
|
||||
|
||||
private void setAnalyticsListener() {
|
||||
player1.addAnalyticsListener(new AnalyticsListener() {
|
||||
@Override
|
||||
public void onPlaybackStateChanged(
|
||||
@NonNull EventTime eventTime, int state) {
|
||||
Log.d(TAG, "onPlaybackStateChanged(1) called with: eventTime = [" + eventTime + "], state = [" + state + "]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDroppedVideoFrames(
|
||||
@NonNull EventTime eventTime, int droppedFrames, long elapsedMs) {
|
||||
Log.d(TAG, "onDroppedVideoFrames(1) called with: eventTime = [" + eventTime + "], droppedFrames = [" + droppedFrames + "], elapsedMs = [" + elapsedMs + "]");
|
||||
}
|
||||
});
|
||||
|
||||
player2.addAnalyticsListener(new AnalyticsListener() {
|
||||
@Override
|
||||
public void onPlaybackStateChanged(
|
||||
@NonNull EventTime eventTime, int state) {
|
||||
Log.d(TAG, "onPlaybackStateChanged(2) called with: eventTime = [" + eventTime.totalBufferedDurationMs + "], state = [" + state + "]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDroppedVideoFrames(
|
||||
@NonNull EventTime eventTime, int droppedFrames, long elapsedMs) {
|
||||
Log.d(TAG, "onDroppedVideoFrames(2) called with: eventTime = [" + eventTime + "], droppedFrames = [" + droppedFrames + "], elapsedMs = [" + elapsedMs + "]");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 延迟1秒还未恢复播放则认为卡顿了,可以切分辨率了
|
||||
*/
|
||||
private final Runnable buffRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
playBufferIndex = 0;
|
||||
listener.onPlaybackStateChanged(Player.STATE_BUFFERING);
|
||||
replay();
|
||||
}
|
||||
};
|
||||
|
||||
private void setListener() {
|
||||
player1.addListener(new Player.Listener() {
|
||||
@Override
|
||||
public void onPlaybackStateChanged(int playbackState) {
|
||||
Player.Listener.super.onPlaybackStateChanged(playbackState);
|
||||
Log.i(TAG, "onPlaybackStateChanged 1: " + playbackState);
|
||||
if (playbackState == Player.STATE_READY && !player1.isPlaying()) {
|
||||
player2.stop();
|
||||
player2.clearVideoSurface();
|
||||
player1.play();
|
||||
Log.i(TAG, "切换播放器1");
|
||||
handler.removeCallbacks(buffRunnable);
|
||||
playBufferIndex = 0;
|
||||
} else if (playbackState == Player.STATE_BUFFERING && status == MODEL_PLAY1 && !isSwitchUrl) {
|
||||
if (listener != null) {
|
||||
if (playBufferIndex++ == 0) {
|
||||
handler.postDelayed(buffRunnable, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIsPlayingChanged(boolean isPlaying) {
|
||||
Player.Listener.super.onIsPlayingChanged(isPlaying);
|
||||
if (isPlaying) {
|
||||
Log.i(TAG, "onIsPlayingChanged1: 播放了");
|
||||
//player1.setVideoSurfaceView(mainView);
|
||||
if (log_buffer_time != -1) {
|
||||
double tmp = (System.currentTimeMillis() - log_buffer_time) / 1000;
|
||||
if (tmp > log_buffer_max_time) {
|
||||
log_buffer_max_time = tmp;
|
||||
}
|
||||
//ToastUtil.show(String.format(Locale.CHINA, "从加载到播放 = %.3f,最大耗时 = %.3f", tmp, log_buffer_max_time));
|
||||
log_buffer_time = -1;
|
||||
}
|
||||
mainView.setPlayer(player1);
|
||||
status = MODEL_PLAY1;
|
||||
isSwitchUrl = false;
|
||||
handler.removeCallbacks(buffRunnable);
|
||||
if (getNextPlayer().isPlaying()) {
|
||||
getNextPlayer().stop();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onIsPlayingChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoSizeChanged(@NonNull VideoSize videoSize) {
|
||||
Player.Listener.super.onVideoSizeChanged(videoSize);
|
||||
setViewResizeMode(videoSize.height > videoSize.width);
|
||||
Log.i(TAG, "onVideoSizeChanged: width = " + videoSize.width + " height = " + videoSize.height);
|
||||
if (listener != null) {
|
||||
listener.onVideoSizeChanged(videoSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIsLoadingChanged(boolean isLoading) {
|
||||
Player.Listener.super.onIsLoadingChanged(isLoading);
|
||||
Log.i(TAG, "onIsLoadingChanged: 1 " + isLoading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerError(@NonNull PlaybackException error) {
|
||||
Player.Listener.super.onPlayerError(error);
|
||||
error.printStackTrace();
|
||||
replay();
|
||||
}
|
||||
});
|
||||
|
||||
player2.addListener(new Player.Listener() {
|
||||
@Override
|
||||
public void onPlaybackStateChanged(int playbackState) {
|
||||
Player.Listener.super.onPlaybackStateChanged(playbackState);
|
||||
Log.i(TAG, "onPlaybackStateChanged 2: " + playbackState);
|
||||
if (playbackState == Player.STATE_READY && !player2.isPlaying()) {
|
||||
player1.stop();
|
||||
player1.clearVideoSurface();
|
||||
player2.play();
|
||||
Log.i(TAG, "切换播放器2 " + player2.isPlaying());
|
||||
handler.removeCallbacks(buffRunnable);
|
||||
playBufferIndex = 0;
|
||||
} else if (playbackState == Player.STATE_BUFFERING && status == MODEL_PLAY2 && !isSwitchUrl) {
|
||||
if (listener != null) {
|
||||
if (playBufferIndex++ == 0) {
|
||||
handler.postDelayed(buffRunnable, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIsPlayingChanged(boolean isPlaying) {
|
||||
Player.Listener.super.onIsPlayingChanged(isPlaying);
|
||||
if (isPlaying) {
|
||||
Log.i(TAG, "onIsPlayingChanged2: 播放了");
|
||||
//player2.setVideoSurfaceView(mainView);
|
||||
mainView.setPlayer(player2);
|
||||
double tmp = (System.currentTimeMillis() - log_buffer_time) / 1000;
|
||||
if (tmp > log_buffer_max_time) {
|
||||
log_buffer_max_time = tmp;
|
||||
}
|
||||
//ToastUtil.show(String.format(Locale.CHINA, "从加载到播放 = %.3f,最大耗时 = %.3f", tmp, log_buffer_max_time));
|
||||
log_buffer_time = -1;
|
||||
status = MODEL_PLAY2;
|
||||
if (getNextPlayer().isPlaying()) {
|
||||
getNextPlayer().stop();
|
||||
}
|
||||
handler.removeCallbacks(buffRunnable);
|
||||
isSwitchUrl = false;
|
||||
if (listener != null) {
|
||||
listener.onIsPlayingChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoSizeChanged(@NonNull VideoSize videoSize) {
|
||||
Player.Listener.super.onVideoSizeChanged(videoSize);
|
||||
setViewResizeMode(videoSize.height > videoSize.width);
|
||||
if (listener != null) {
|
||||
listener.onVideoSizeChanged(videoSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIsLoadingChanged(boolean isLoading) {
|
||||
Player.Listener.super.onIsLoadingChanged(isLoading);
|
||||
Log.i(TAG, "onIsLoadingChanged: 2 " + isLoading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerError(@NonNull PlaybackException error) {
|
||||
Player.Listener.super.onPlayerError(error);
|
||||
error.printStackTrace();
|
||||
replay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始播放
|
||||
*
|
||||
* @param url 地址
|
||||
*/
|
||||
public void startUrl(String url) {
|
||||
if (url != null && url.equals(this.url)) return;
|
||||
Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode());
|
||||
handler.removeCallbacks(buffRunnable);
|
||||
this.url = url;
|
||||
isSwitchUrl = true;
|
||||
playBufferIndex = 0;
|
||||
log_buffer_time = System.currentTimeMillis();
|
||||
//getNowPlayer().setVideoSurfaceView(mainView);
|
||||
mainView.setKeepContentOnPlayerReset(false);
|
||||
mainView.setPlayer(getNowPlayer());
|
||||
mainView.setKeepContentOnPlayerReset(true);
|
||||
getNowPlayer().setMediaItem(createMediaItem(url));
|
||||
getNowPlayer().prepare();
|
||||
getNowPlayer().play();
|
||||
handler.postDelayed(buffRunnable, 10000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无缝切换
|
||||
*
|
||||
* @param url 地址
|
||||
*/
|
||||
public void switchUrl(String url) {
|
||||
if (url != null && url.equals(this.url)) return;
|
||||
Log.i(TAG, "switchUrl: " + url + " src : " + this.url);
|
||||
this.url = url;
|
||||
playBufferIndex = 0;
|
||||
isSwitchUrl = true;
|
||||
log_buffer_time = System.currentTimeMillis();
|
||||
mainView.setKeepContentOnPlayerReset(true);
|
||||
getNextPlayer().setMediaItem(createMediaItem(url));
|
||||
getNextPlayer().prepare();
|
||||
}
|
||||
|
||||
private MediaItem createMediaItem(String url) {
|
||||
return MediaItem.fromUri(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前播放器
|
||||
*/
|
||||
public ExoPlayer getNowPlayer() {
|
||||
return status == MODEL_PLAY1 ? player1 : player2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个播放器。
|
||||
*/
|
||||
private ExoPlayer getNextPlayer() {
|
||||
return status == MODEL_PLAY1 ? player2 : player1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否正在播放
|
||||
*/
|
||||
public boolean isPlaying() {
|
||||
if (getNowPlayer() != null) {
|
||||
return getNowPlayer().isPlaying();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止播放
|
||||
*/
|
||||
public void stop() {
|
||||
if (getNowPlayer() != null) {
|
||||
getNowPlayer().stop();
|
||||
}
|
||||
clearUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始播放
|
||||
*/
|
||||
public void play() {
|
||||
getNowPlayer().play();
|
||||
}
|
||||
|
||||
public void replay() {
|
||||
Log.i(TAG, "replay: 重载播放");
|
||||
if (getNowPlayer() != null) {
|
||||
getNowPlayer().stop();
|
||||
}
|
||||
if (getNextPlayer() != null) {
|
||||
getNextPlayer().stop();
|
||||
}
|
||||
String tmp = url;
|
||||
url = null;
|
||||
startUrl(tmp);
|
||||
}
|
||||
|
||||
public void clearFrame() {
|
||||
mainView.setKeepContentOnPlayerReset(false);
|
||||
if (mainView.getVideoSurfaceView() != null) {
|
||||
mainView.setPlayer(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放播放器
|
||||
*/
|
||||
public void release() {
|
||||
Log.i(TAG, "release: 释放播放器");
|
||||
if (player1 != null) {
|
||||
player1.clearVideoSurface();
|
||||
player1.release();
|
||||
}
|
||||
if (player2 != null) {
|
||||
player2.clearVideoSurface();
|
||||
player2.release();
|
||||
}
|
||||
player1 = null;
|
||||
player2 = null;
|
||||
mainView.setKeepContentOnPlayerReset(false);
|
||||
mainView.setPlayer(null);
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainView.getLayoutParams();
|
||||
layoutParams.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
|
||||
mainView.setLayoutParams(layoutParams);
|
||||
mainView.removeAllViews();
|
||||
mainView.requestLayout();
|
||||
handler.removeCallbacks(buffRunnable);
|
||||
}
|
||||
|
||||
public void clearUrl() {
|
||||
url = "";
|
||||
handler.removeCallbacks(buffRunnable);
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
if (url == null) {
|
||||
url = "";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yunbao.live.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@@ -157,6 +158,22 @@ public class LiveTextRender {
|
||||
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF86C")), giftIndexOf, giftIndexOf + giftSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
mTextView.setText(builder);
|
||||
}
|
||||
/**
|
||||
* 幸运100%活动
|
||||
*/
|
||||
public void lucky100(Context mContext, TextView mTextView, MsgModel msgModel){
|
||||
String msg = mContext.getString(R.string.lucky_100);
|
||||
msg = String.format(msg, msgModel.getUserName(), msgModel.getGiftName());
|
||||
int unameIndexOf = msg.indexOf(msgModel.getUserName());
|
||||
int giftIndexOf = msg.indexOf(msgModel.getGiftName());
|
||||
int unameSize = msgModel.getUserName().length();
|
||||
int giftSize = msgModel.getGiftName().length();
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
builder.append(msg);
|
||||
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#78FEFF")), unameIndexOf, unameIndexOf + unameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF86C")), giftIndexOf, giftIndexOf + giftSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
mTextView.setText(builder);
|
||||
}
|
||||
|
||||
public void aiAutomaticSpeech(Context activity, TextView textView, AiAutomaticSpeechModel model) {
|
||||
ImgLoader.displayDrawable(activity, model.getIcon(), new ImgLoader.DrawableCallback() {
|
||||
@@ -408,6 +425,11 @@ public class LiveTextRender {
|
||||
*/
|
||||
public void getLevelImage(Context mContext, int userLevel, ImgLoader.DrawableCallback callback) {
|
||||
mCallback = callback;
|
||||
if(mContext instanceof Activity){
|
||||
if(((Activity)mContext).isDestroyed()){
|
||||
mContext=CommonAppContext.getTopActivity();
|
||||
}
|
||||
}
|
||||
List<NewLevelModel> models = new NewLevelManager(mContext).getNewLevelModels();
|
||||
String imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png";
|
||||
for (NewLevelModel newLevelModel : models) {
|
||||
|
||||
@@ -32,9 +32,10 @@ public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushV
|
||||
protected ViewGroup mLeftContainer;
|
||||
protected ViewGroup mRightContainer;
|
||||
protected ViewGroup mPkContainer;
|
||||
public static FrameLayout mPreView,mPreView1,dr1_preview,dr2_preview,dr3_preview,dr4_preview;
|
||||
public static ImageView leave;
|
||||
public FrameLayout mPreView, mPreView1, cameraPreview3, dr1_preview, dr2_preview, dr3_preview, dr4_preview;
|
||||
public ImageView leave;
|
||||
protected boolean mOpenCamera;//是否选择了相机
|
||||
public LinearLayout camera;
|
||||
|
||||
//倒计时
|
||||
protected TextView mCountDownText;
|
||||
|
||||
@@ -190,8 +190,12 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder {
|
||||
|
||||
public void setTime(String content) {
|
||||
if (mTime != null) {
|
||||
|
||||
mTime.setText(content);
|
||||
Log.i("vvvs",content);
|
||||
if(content.trim().equals("00:00")){
|
||||
mTime.setText("結算中");
|
||||
}else {
|
||||
mTime.setText(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.yunbao.live.views;
|
||||
|
||||
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -7,24 +9,32 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.event.LivePushRyEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
@@ -32,24 +42,32 @@ import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.AbsViewHolder;
|
||||
import com.yunbao.common.views.LiveClarityCustomPopup;
|
||||
import com.yunbao.common.views.LiveOpenCustomPopup;
|
||||
import com.yunbao.common.views.LiveRobotSettingCustomPopup;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.faceunity.FaceManager;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveNewWishListDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveTimeDialogFragment;
|
||||
import com.yunbao.live.event.LiveAudienceEvent;
|
||||
import com.yunbao.live.http.LiveHttpConsts;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream;
|
||||
import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
|
||||
import cn.rongcloud.rtc.base.RCRTCParamsType;
|
||||
|
||||
public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener {
|
||||
|
||||
@@ -59,7 +77,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
private ProcessImageUtil mImageUtil;
|
||||
private File mAvatarFile;
|
||||
private TextView mLiveClass;
|
||||
private TextView mLiveTypeTextView;//房间类型TextView
|
||||
private TextView mLiveTypeTextView, liveClarity;//房间类型TextView
|
||||
private TextView mLiveWishListTextView;//心愿单TextView
|
||||
private int mLiveClassID;//直播频道id
|
||||
private int mLiveType;//房间类型
|
||||
@@ -70,6 +88,9 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
private LiveClassBean classBean;
|
||||
private FaceManager manager;
|
||||
private TextView faceTextView;//提示人脸未检测到的TextView
|
||||
private ImageView imgClarity;
|
||||
private int selectClarity = 1;
|
||||
private LiveOpenCustomPopup liveOpenCustomPopup;
|
||||
|
||||
public LiveNewReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) {
|
||||
super(context, parentView, liveSdk);
|
||||
@@ -90,6 +111,8 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
@Override
|
||||
public void init() {
|
||||
mRootView = (ConstraintLayout) findViewById(R.id.traceroute_rootview);
|
||||
imgClarity = (ImageView) findViewById(R.id.img_clarity);
|
||||
liveClarity = (TextView) findViewById(R.id.live_clarity);
|
||||
mRootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -163,6 +186,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
findViewById(R.id.btn_start_live).setOnClickListener(this);
|
||||
findViewById(R.id.btn_wishlist).setOnClickListener(this);
|
||||
findViewById(R.id.btn_horizontally).setOnClickListener(this);
|
||||
|
||||
if (manager != null) {
|
||||
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
@@ -180,13 +204,135 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
});
|
||||
//新美颜
|
||||
setFaceUnity(true);
|
||||
|
||||
}
|
||||
//设置清晰度
|
||||
// DeviceUtils.getMemory(mContext); //获取可用内存
|
||||
// DeviceUtils.getNetSpeed(mContext);//获取当前上传网速
|
||||
// Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext));
|
||||
|
||||
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
|
||||
setSelectClarity(IMLoginManager.get(mContext).getSelectClarity());
|
||||
ViewClicksAntiShake
|
||||
.clicksAntiShake(
|
||||
findViewById(R.id.btn_live_clarity), () -> {
|
||||
|
||||
LiveClarityCustomPopup liveClarityCustomPopup =
|
||||
new LiveClarityCustomPopup(mContext,
|
||||
IMLoginManager.get(mContext).getSelectClarity(),
|
||||
IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
|
||||
new XPopup.Builder(mContext)
|
||||
.setPopupCallback(new XPopupCallback() {
|
||||
@Override
|
||||
public void onCreated(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(BasePopupView popupView) {
|
||||
setSelectClarity(liveClarityCustomPopup.getSelectClarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDismiss(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(BasePopupView popupView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickOutside(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
})
|
||||
.asCustom(liveClarityCustomPopup)
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
private void setSelectClarity(int selectClarity) {
|
||||
|
||||
this.selectClarity = selectClarity;
|
||||
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
|
||||
switch (selectClarity) {
|
||||
case 0:
|
||||
imgClarity.setImageResource(R.mipmap.icon_sd);
|
||||
liveClarity.setText(R.string.standard_clear);
|
||||
break;
|
||||
case 1:
|
||||
imgClarity.setImageResource(R.mipmap.icon_hd);
|
||||
liveClarity.setText(R.string.high_definition);
|
||||
break;
|
||||
case 2:
|
||||
imgClarity.setImageResource(R.mipmap.icon_fhd);
|
||||
liveClarity.setText(R.string.ultra_hd);
|
||||
break;
|
||||
}
|
||||
if (liveOpenCustomPopup != null) {
|
||||
liveOpenCustomPopup.setSelectClarity(selectClarity);
|
||||
}
|
||||
//設置開播分辨率
|
||||
RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||
int minRate = 200;
|
||||
int maxRate = 900;
|
||||
switch (selectClarity) {
|
||||
case 0:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||
minRate = 200;
|
||||
maxRate = 900;
|
||||
break;
|
||||
case 1:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
|
||||
minRate = 250;
|
||||
maxRate = 2200;
|
||||
break;
|
||||
case 2:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
|
||||
minRate = 400;
|
||||
maxRate = 4000;
|
||||
break;
|
||||
}
|
||||
RCRTCVideoStreamConfig config =
|
||||
RCRTCVideoStreamConfig.Builder.create()
|
||||
.setMinRate(minRate)
|
||||
.setMaxRate(maxRate)
|
||||
.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_15)
|
||||
.setVideoResolution(rcrtcVideoResolution)
|
||||
.build();
|
||||
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);
|
||||
Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
|
||||
//重新发布一下流
|
||||
Bus.get().post(new LivePushRyEvent());
|
||||
}
|
||||
|
||||
public void setManager(FaceManager manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
@@ -211,8 +357,164 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
} else if (i == R.id.btn_room_type) {
|
||||
chooseLiveType();
|
||||
} else if (i == R.id.btn_start_live) {
|
||||
startLive();
|
||||
if (mLiveClassID == 0) {
|
||||
ToastUtil.show(R.string.live_choose_live_class);
|
||||
return;
|
||||
}
|
||||
// startLive();
|
||||
liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity(), classBean, liveRoomTypeBean)
|
||||
.setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() {
|
||||
@Override
|
||||
|
||||
public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) {
|
||||
if (classModel != null) {
|
||||
classBean = classModel;
|
||||
mLiveClassID = classBean.getId();
|
||||
}
|
||||
liveRoomTypeBean = liveRoomTypeModel;
|
||||
mLiveType = liveRoomTypeModel.getId();
|
||||
startLiveInit();
|
||||
liveOpenCustomPopup = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectClarity(int selectClarity) {
|
||||
LiveClarityCustomPopup liveClarityCustomPopup =
|
||||
new LiveClarityCustomPopup(mContext,
|
||||
IMLoginManager.get(mContext).getSelectClarity(),
|
||||
IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
|
||||
new XPopup.Builder(mContext)
|
||||
.setPopupCallback(new XPopupCallback() {
|
||||
@Override
|
||||
public void onCreated(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(BasePopupView popupView) {
|
||||
setSelectClarity(liveClarityCustomPopup.getSelectClarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDismiss(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(BasePopupView popupView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickOutside(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
})
|
||||
.asCustom(liveClarityCustomPopup)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openRobot() {
|
||||
LiveRobotSettingCustomPopup liveRobotSettingCustomPopup = new LiveRobotSettingCustomPopup(mContext);
|
||||
new XPopup.Builder(mContext)
|
||||
.setPopupCallback(new XPopupCallback() {
|
||||
@Override
|
||||
public void onCreated(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(BasePopupView popupView) {
|
||||
if (liveOpenCustomPopup != null) {
|
||||
liveOpenCustomPopup.initDate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDismiss(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(BasePopupView popupView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickOutside(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
})
|
||||
.asCustom(liveRobotSettingCustomPopup)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openLiveRoomType(LiveRoomTypeBean liveRoomTypeModel) {
|
||||
liveRoomTypeBean = liveRoomTypeModel;
|
||||
mLiveType = liveRoomTypeModel.getId();
|
||||
chooseLiveType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openLiveClass(LiveClassBean classModel) {
|
||||
if (classModel != null) {
|
||||
classBean = classModel;
|
||||
mLiveClassID = classBean.getId();
|
||||
}
|
||||
chooseLiveClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openWishlist() {
|
||||
//点击心愿单
|
||||
openWishListWindow();
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(liveOpenCustomPopup)
|
||||
.show();
|
||||
} else if (i == R.id.btn_locaiton) {
|
||||
switchLocation();
|
||||
} else if (i == R.id.btn_horizontally) {
|
||||
@@ -249,6 +551,16 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
|
||||
if (mContext instanceof LiveRyAnchorActivity) {
|
||||
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void updateStart(LiveAudienceEvent event) {
|
||||
if (event.getType() == WISH_LIST_UPDATE) {
|
||||
if (liveOpenCustomPopup != null) {
|
||||
liveOpenCustomPopup.initDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +648,9 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
classBean = bean;
|
||||
mLiveClassID = classBean.getId();
|
||||
mLiveClass.setText(bean.getName());
|
||||
if (liveOpenCustomPopup != null) {
|
||||
liveOpenCustomPopup.setClassBean(classBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
|
||||
@@ -355,6 +670,8 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
/**
|
||||
* 选择直播类型
|
||||
*/
|
||||
private LiveRoomTypeBean liveRoomTypeBean = new LiveRoomTypeBean(0, WordUtil.getString(R.string.live_room_public));
|
||||
|
||||
private void chooseLiveType() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(Constants.CHECKED_ID, mLiveType);
|
||||
@@ -363,6 +680,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
fragment.setCallback(new CommonCallback<LiveRoomTypeBean>() {
|
||||
@Override
|
||||
public void callback(LiveRoomTypeBean bean) {
|
||||
liveRoomTypeBean = bean;
|
||||
switch (bean.getId()) {
|
||||
case Constants.LIVE_TYPE_NORMAL:
|
||||
onLiveTypeNormal(bean);
|
||||
@@ -377,6 +695,9 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
onLiveTypeTime(bean);
|
||||
break;
|
||||
}
|
||||
if (liveOpenCustomPopup != null) {
|
||||
liveOpenCustomPopup.setLiveRoomTypeBean(liveRoomTypeBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
|
||||
@@ -472,7 +793,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
/**
|
||||
* 点击开始直播按钮
|
||||
*/
|
||||
private void startLive() {
|
||||
private void startLiveInit() {
|
||||
boolean startPreview = ((LiveRyAnchorActivity) mContext).isStartPreview();
|
||||
// if (!startPreview) {
|
||||
// ToastUtil.show(R.string.please_wait);
|
||||
@@ -498,7 +819,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
return;
|
||||
}
|
||||
String title = mEditTitle.getText().toString().trim();
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, new HttpCallback() {
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, final String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
|
||||
@@ -128,7 +128,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
|
||||
* @param url 流地址
|
||||
*/
|
||||
@Override
|
||||
public void play(String url) {
|
||||
public void play(String url,int playModel) {
|
||||
mPlayer = new V2TXLivePlayerImpl(mContext);
|
||||
|
||||
if (TextUtils.isEmpty(url) || mVideoView == null) {
|
||||
@@ -142,6 +142,11 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchStream(String url, int playModel) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
|
||||
@@ -6,46 +6,55 @@ import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
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.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
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.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.lzy.okserver.OkDownload;
|
||||
import com.lzy.okserver.download.DownloadTask;
|
||||
import com.tencent.live2.V2TXLiveDef;
|
||||
import com.tencent.live2.V2TXLivePlayer;
|
||||
import com.tencent.live2.V2TXLivePlayerObserver;
|
||||
import com.tencent.live2.impl.V2TXLivePlayerImpl;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
import com.yunbao.common.bean.CrashSaveBean;
|
||||
import com.yunbao.common.bean.EnterRoomNewModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
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.MicStatusManager;
|
||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
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.event.LiveAudienceEvent;
|
||||
import com.yunbao.live.utils.LiveExoPlayerManager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -56,7 +65,6 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
||||
@@ -79,7 +87,10 @@ import cn.rongcloud.rtc.base.RCRTCMediaType;
|
||||
import cn.rongcloud.rtc.base.RCRTCParamsType;
|
||||
import cn.rongcloud.rtc.base.RCRTCRemoteVideoFrame;
|
||||
import cn.rongcloud.rtc.base.RCRTCRoomType;
|
||||
import cn.rongcloud.rtc.base.RCRTCStreamType;
|
||||
import cn.rongcloud.rtc.base.RTCErrorCode;
|
||||
import cn.rongcloud.rtc.center.stream.RCRTCAudioInputStreamImpl;
|
||||
import cn.rongcloud.rtc.core.RendererCommon;
|
||||
|
||||
public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
|
||||
@@ -89,7 +100,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
private ViewGroup mLeftContainer;
|
||||
private ViewGroup mRightContainer;
|
||||
private RelativeLayout mPkContainer;
|
||||
public static TXCloudVideoView mVideoView;
|
||||
public StyledPlayerView mVideoView;
|
||||
|
||||
private View mLoading, mLoading2;
|
||||
private ImageView mCover;
|
||||
@@ -100,21 +111,21 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
|
||||
private boolean mPausedPlay;//是否被动暂停了播放
|
||||
public int landscape; //1h 2s
|
||||
public static Context contexts;
|
||||
public V2TXLivePlayer mPlayer;
|
||||
public static FrameLayout ry_view;
|
||||
public Context contexts;
|
||||
public FrameLayout ry_view;
|
||||
|
||||
private static final int VIDEO_VERTICAL = 1;
|
||||
private static final int VIDEO_HORIZONTAL = 2;
|
||||
int videoLandscape; // 视频方向,1=竖屏,2=横屏
|
||||
private static final int VIDEO_VERTICAL = 2;
|
||||
private static final int VIDEO_HORIZONTAL = 1;
|
||||
int videoLandscape = -1; // 视频方向,2=竖屏,1=横屏
|
||||
|
||||
static int vHeight;//视频高
|
||||
private TextView debugView;
|
||||
|
||||
private LiveExoPlayerManager mPlayer;
|
||||
private boolean isPk = false;
|
||||
|
||||
//0未申请1申请中2连麦中
|
||||
RCRTCRoom rcrtcRoom;
|
||||
String purl;
|
||||
String purl, srcUrl;
|
||||
|
||||
public int getLandscape() {
|
||||
return landscape;
|
||||
@@ -135,13 +146,15 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Log.i(TAG, "init: 初始化播放器ViewHolder");
|
||||
EventBus.getDefault().register(this);
|
||||
Bus.getOn(this);
|
||||
mRoot = (ViewGroup) findViewById(R.id.root);
|
||||
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
|
||||
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
|
||||
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
|
||||
mPkContainer = (RelativeLayout) findViewById(R.id.pk_container);
|
||||
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
|
||||
mVideoView = (StyledPlayerView) findViewById(R.id.video_view);
|
||||
ry_view = (FrameLayout) findViewById(R.id.ry_view);
|
||||
leave = (ImageView) findViewById(R.id.leave);
|
||||
mLoading = findViewById(R.id.loading);
|
||||
@@ -154,9 +167,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams();
|
||||
params.height = vHeight;
|
||||
mPkContainer.requestLayout();
|
||||
mPlayer = new V2TXLivePlayerImpl(mContext);
|
||||
mPlayer.setRenderView(mVideoView);
|
||||
|
||||
mPlayer = new LiveExoPlayerManager(mContext);
|
||||
mPlayer.setMainView(mVideoView);
|
||||
mPlayer.setListener(new ExoPlayerListener());
|
||||
debugView = new TextView(mContext);
|
||||
debugView.setBackgroundColor(Color.WHITE);
|
||||
|
||||
@@ -192,7 +206,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
|
||||
@Override
|
||||
public synchronized void setLiveBeanLandscape(int landscape) {
|
||||
// landscape=1;
|
||||
Log.i(TAG, "setLiveBeanLandscape: " + landscape);
|
||||
this.landscape = landscape;
|
||||
this.videoLandscape = landscape;
|
||||
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
|
||||
if (landscape == 2) {
|
||||
Log.i("收到socket--->", "还原9:16");
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||
@@ -234,6 +252,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLiveEnterRoomNewModel(EnterRoomNewModel data) {
|
||||
super.setLiveEnterRoomNewModel(data);
|
||||
isPk = data.getEnterRoomInfo().getIsconnection().equals("1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停播放
|
||||
*/
|
||||
@@ -247,13 +271,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
*/
|
||||
@Override
|
||||
public void resumePlay() {
|
||||
if (mPlayer.isPlaying() != 1) {
|
||||
if (!mPlayer.isPlaying()) {
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(() -> {
|
||||
mPlayer.stopPlay();
|
||||
int val = mPlayer.startPlay(purl);
|
||||
mPlayer.replay();
|
||||
// ToastUtil.show("强制播放" + val);
|
||||
Log.i(TAG, "强制播放: " + val);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +286,53 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
* @param url 流地址
|
||||
*/
|
||||
@Override
|
||||
public void play(String url) {
|
||||
public void play(String url, int playModel) {
|
||||
srcUrl = url;
|
||||
PLAY_MODEL = playModel;
|
||||
Log.i(TAG, "play" + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape" + videoLandscape);
|
||||
if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
|
||||
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
|
||||
if (landscape == VIDEO_VERTICAL && !isPk) {
|
||||
url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
|
||||
} else if (landscape == VIDEO_HORIZONTAL || isPk) {
|
||||
url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
|
||||
}
|
||||
} else if (!url.contains(videoFps[0] + ".flv")) {
|
||||
mPlayer.setViewResizeMode(false);
|
||||
}
|
||||
Log.e("purl121", url);
|
||||
|
||||
if (TextUtils.isEmpty(url) || mVideoView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(url) || mVideoView == null) {
|
||||
return;
|
||||
}
|
||||
if (mPlayer.isPlaying()) {
|
||||
mPlayer.stop();
|
||||
mPlayer.clearUrl();
|
||||
}
|
||||
mPlayer.startUrl(url);
|
||||
purl = url;
|
||||
onPrepared();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchStream(String url, int playModel) {
|
||||
srcUrl = url;
|
||||
PLAY_MODEL = playModel;
|
||||
Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape + " ispk = " + isPk + " bean = " + roomModel.getEnterRoomInfo().getIsconnection());
|
||||
if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
|
||||
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
|
||||
if (landscape == VIDEO_VERTICAL && !isPk) {
|
||||
url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
|
||||
} else if (landscape == VIDEO_HORIZONTAL || isPk) {
|
||||
url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
|
||||
}
|
||||
} else if (!url.contains(videoFps[0] + ".flv")) {
|
||||
mPlayer.setViewResizeMode(false);
|
||||
}
|
||||
Log.e("purl121", url);
|
||||
|
||||
if (TextUtils.isEmpty(url) || mVideoView == null) {
|
||||
@@ -275,150 +343,84 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
if (TextUtils.isEmpty(url) || mVideoView == null) {
|
||||
return;
|
||||
}
|
||||
mVideoView.clearLastFrame(true);
|
||||
mPlayer.setObserver(new V2TXLivePlayerObserver() {
|
||||
String TAG = "播放流";
|
||||
|
||||
@Override
|
||||
public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
||||
super.onError(player, code, msg, extraInfo);
|
||||
Log.i(TAG, "onError: player = " + player + ", code = " + code + ", msg = " + msg + ", extraInfo = " + extraInfo);
|
||||
debugView.setText("播放出错code=" + code + " msg=" + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
||||
super.onWarning(player, code, msg, extraInfo);
|
||||
Log.i(TAG, "onWarning: " + "player = " + player + ", code = " + code + ", msg = " + msg + ", extraInfo = " + extraInfo);
|
||||
if (code == 2105) {
|
||||
// mPlayer.resumeVideo();
|
||||
// mPlayer.resumeAudio();
|
||||
mPlayer.stopPlay();
|
||||
mPlayer.startPlay(purl);
|
||||
}
|
||||
debugView.setText("播放警告code=" + code + " msg=" + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle extraInfo) {
|
||||
super.onVideoPlayStatusUpdate(player, status, reason, extraInfo);
|
||||
//Log.i(TAG, "onVideoPlayStatusUpdate: " + "player = " + player + ", status = " + status + ", reason = " + reason + ", extraInfo = " + extraInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAudioPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle extraInfo) {
|
||||
super.onAudioPlayStatusUpdate(player, status, reason, extraInfo);
|
||||
//Log.i(TAG, "onAudioPlayStatusUpdate: " + "player = " + player + ", status = " + status + ", reason = " + reason + ", extraInfo = " + extraInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayoutVolumeUpdate(V2TXLivePlayer player, int volume) {
|
||||
super.onPlayoutVolumeUpdate(player, volume);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatisticsUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayerStatistics statistics) {
|
||||
super.onStatisticsUpdate(player, statistics);
|
||||
Map<String, DownloadTask> taskMap = OkDownload.getInstance().getTaskMap();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("|");
|
||||
for (String key : taskMap.keySet()) {
|
||||
DownloadTask task = taskMap.get(key);
|
||||
buffer.append(task.progress.fileName).append(":");
|
||||
int status = task.progress.status;
|
||||
switch (status) {
|
||||
case 0:
|
||||
buffer.append("无状态");
|
||||
break;
|
||||
case 1:
|
||||
buffer.append("等待");
|
||||
break;
|
||||
case 2:
|
||||
buffer.append("下载中:").append(task.progress.fraction);
|
||||
break;
|
||||
case 3:
|
||||
buffer.append("暂停");
|
||||
break;
|
||||
case 4:
|
||||
buffer.append("错误");
|
||||
break;
|
||||
case 5:
|
||||
buffer.append("完成");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
buffer.append("|");
|
||||
}
|
||||
hideCover();
|
||||
String debugText = "视频码率:" + statistics.videoBitrate + "\n" +
|
||||
"音频码率:" + statistics.audioBitrate + "\n" +
|
||||
"FPS:" + statistics.fps + "\n" +
|
||||
"CPU:" + statistics.appCpu + "\n" +
|
||||
"剩余内存:" + DeviceUtils.getMemory(mContext) + "\n" +
|
||||
"分辨率:" + statistics.height + "x" + statistics.width + "\n" +
|
||||
"播放状态:" + mPlayer.isPlaying() + "\n" +
|
||||
"运行时间:" + (System.currentTimeMillis() - CrashSaveBean.getInstance().getStartTime()) / 1000 + "\n";
|
||||
debugView.setText(debugText);
|
||||
Log.i(TAG, "onStatisticsUpdate: " + JSON.toJSONString(statistics) + " |当前下载数 : " + OkDownload.getInstance().getTaskMap().size() + buffer);
|
||||
if (statistics.height > statistics.width) {
|
||||
videoLandscape = VIDEO_VERTICAL;
|
||||
} else {
|
||||
videoLandscape = VIDEO_HORIZONTAL;
|
||||
}
|
||||
if (statistics.fps == 0) {
|
||||
OkDownload.getInstance().pauseAll();
|
||||
} else {
|
||||
OkDownload.getInstance().startAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSnapshotComplete(V2TXLivePlayer player, Bitmap image) {
|
||||
super.onSnapshotComplete(player, image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveDef.V2TXLiveVideoFrame videoFrame) {
|
||||
super.onRenderVideoFrame(player, videoFrame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) {
|
||||
super.onReceiveSeiMessage(player, payloadType, data);
|
||||
}
|
||||
});
|
||||
|
||||
mPlayer.switchUrl(url);
|
||||
purl = url;
|
||||
int V2TXLiveCode = mPlayer.startPlay(url);
|
||||
onPrepared();
|
||||
|
||||
}
|
||||
|
||||
boolean tmpPk = false;
|
||||
String waitNextUrl = null;
|
||||
|
||||
@Override
|
||||
public void switchStreamPk(boolean isPk) {
|
||||
super.switchStreamPk(isPk);
|
||||
Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2 = " + this.isPk);
|
||||
if (this.isPk && tmpPk) return;
|
||||
if (isPk && !tmpPk || this.isPk) {
|
||||
mPlayer.setViewResizeMode(false);
|
||||
String url;
|
||||
if (PLAY_MODEL != -1) {
|
||||
url = srcUrl.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
|
||||
} else {
|
||||
url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv");
|
||||
}
|
||||
if (!tmpPk) {
|
||||
waitNextUrl = url;
|
||||
}
|
||||
mPlayer.switchUrl(srcUrl);
|
||||
tmpPk = true;
|
||||
} else if (!isPk) {
|
||||
tmpPk = false;
|
||||
if (landscape == VIDEO_VERTICAL && PLAY_MODEL != -1) {
|
||||
waitNextUrl = srcUrl.replace(".flv", videoRatioVertical[PLAY_MODEL] + videoFps[0] + ".flv");
|
||||
} else if (landscape == VIDEO_HORIZONTAL && PLAY_MODEL != -1) {
|
||||
waitNextUrl = srcUrl.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
|
||||
} else {
|
||||
waitNextUrl = null;
|
||||
}
|
||||
mPlayer.switchUrl(srcUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFrame() {
|
||||
super.clearFrame();
|
||||
mPlayer.clearFrame();
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP);
|
||||
mVideoView.setLayoutParams(params);
|
||||
mVideoView.requestLayout();
|
||||
|
||||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
|
||||
params1.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||
params1.addRule(RelativeLayout.ALIGN_TOP);
|
||||
ry_view.setLayoutParams(params1);
|
||||
ry_view.requestLayout();
|
||||
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
|
||||
params2.height = DpUtil.dp2px(270);
|
||||
params2.topMargin = DpUtil.dp2px(120);
|
||||
mCover.setLayoutParams(params2);
|
||||
mCover.requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
mEnd = true;
|
||||
mStarted = false;
|
||||
if (mPlayer != null) {
|
||||
mPlayer.stopPlay();
|
||||
mPlayer = null;
|
||||
}
|
||||
if (mVideoView != null) {
|
||||
mVideoView.clearLastFrame(true);
|
||||
mVideoView.removeVideoView();
|
||||
mVideoView = null;
|
||||
}
|
||||
if (leave != null) {
|
||||
leave.setImageDrawable(null);
|
||||
leave = null;
|
||||
mPlayer.stop();
|
||||
mPlayer.release();
|
||||
}
|
||||
Bus.getOff(this);
|
||||
EventBus.getDefault().unregister(this);
|
||||
L.e(TAG, "release------->");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopPlay() {
|
||||
Log.i(TAG, "stopPlay: ");
|
||||
if (mCover != null) {
|
||||
mCover.setAlpha(1f);
|
||||
if (mCover.getVisibility() != View.VISIBLE) {
|
||||
@@ -426,7 +428,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
}
|
||||
if (mPlayer != null) {
|
||||
mPlayer.stopPlay();
|
||||
mPlayer.stop();
|
||||
}
|
||||
stopPlay2();
|
||||
}
|
||||
@@ -436,7 +438,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
|
||||
}
|
||||
|
||||
public static void setViewUP(int i) {
|
||||
@Override
|
||||
public void setViewUP(int i) {
|
||||
if (mVideoView == null) return;
|
||||
Log.e("收", "整理" + i);
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||
@@ -450,6 +453,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||
params1.addRule(RelativeLayout.ALIGN_TOP);
|
||||
ry_view.requestLayout();
|
||||
isPk = true;
|
||||
if (mPlayer.getUrl().contains("848_24.flv") || mPlayer.getUrl().contains("1280_24.flv")) {
|
||||
tmpPk = false;
|
||||
switchStreamPk(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,8 +472,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
if (videoLandscape == VIDEO_VERTICAL) {
|
||||
height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
} else {
|
||||
height = DpUtil.dp2px(285);
|
||||
height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
}
|
||||
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
|
||||
if (landscape == 2) {
|
||||
Log.i("收到socket--->", "还原9:16");
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||
@@ -516,6 +525,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
@Override
|
||||
public void setPkview() {
|
||||
Log.i("收到socket--->", "变成16:9");
|
||||
String url = srcUrl;
|
||||
isPk = true;
|
||||
switchStreamPk(true);
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||
params.height = vHeight;
|
||||
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||
@@ -527,7 +539,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
public synchronized void setPkEndview() {
|
||||
|
||||
Log.i("收收收", landscape + "");
|
||||
|
||||
isPk = false;
|
||||
tmpPk = false;
|
||||
switchStreamPk(false);
|
||||
if (landscape == 2) {
|
||||
Log.i("收到socket--->", "还原9:16");
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||
@@ -542,8 +556,18 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
params.addRule(RelativeLayout.ALIGN_TOP);
|
||||
mVideoView.requestLayout();
|
||||
}
|
||||
if (detailsView != null) {
|
||||
mVideoView.removeView(detailsView);
|
||||
detailsView = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeDetailView(){
|
||||
if (detailsView != null) {
|
||||
mVideoView.removeView(detailsView);
|
||||
detailsView = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewGroup getSmallContainer() {
|
||||
@@ -639,7 +663,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
|
||||
params.topMargin = 0;
|
||||
params.addRule(RelativeLayout.ALIGN_TOP);
|
||||
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270);
|
||||
mVideoView.requestLayout();
|
||||
}
|
||||
|
||||
@@ -649,7 +672,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||
params.height = vHeight;
|
||||
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
|
||||
// mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP);
|
||||
mVideoView.requestLayout();
|
||||
}
|
||||
@@ -713,10 +736,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
Log.e("ry", "退出多人房间成功");
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
public void run() {
|
||||
mPlayer.startPlay(purl);
|
||||
mPlayer.play();
|
||||
Log.e("ry", mPlayer.isPlaying() + "purl" + purl);
|
||||
if (mPlayer.isPlaying() != 1) {
|
||||
mPlayer.startPlay(purl);
|
||||
if (!mPlayer.isPlaying()) {
|
||||
mPlayer.switchUrl(purl);
|
||||
}
|
||||
ry_view.removeAllViews();
|
||||
ry_view.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
@@ -765,6 +788,91 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onOpenDrawer(LiveAudienceEvent event) {
|
||||
if (event.getType() == LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO) {
|
||||
int ban = 0;//全模式都可以选择
|
||||
switch (roomModel.getClarityType() - 1) {
|
||||
case PLAY_MODEL_720://仅允许720(高清),ban掉1080(超高清)模式
|
||||
ban = LiveClarityCustomPopup.BAN_1080;
|
||||
break;
|
||||
case -1://没有该字段
|
||||
case PLAY_MODEL_480://仅允许480(流畅),ban掉1080(超高清)和720(高清)模式
|
||||
ban = LiveClarityCustomPopup.BAN_720;
|
||||
break;
|
||||
|
||||
}
|
||||
LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext,
|
||||
IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR),
|
||||
ban,
|
||||
true);
|
||||
new XPopup.Builder(mContext)
|
||||
.setPopupCallback(new XPopupCallback() {
|
||||
@Override
|
||||
public void onCreated(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(BasePopupView popupView) {
|
||||
int selectClarity = liveClarityCustomPopup.getSelectClarity();
|
||||
if (selectClarity == PLAY_MODEL || selectClarity == IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR))
|
||||
return;
|
||||
if (selectClarity == PLAY_MODEL_ANCHOR) {
|
||||
switchStream(srcUrl, PLAY_MODEL_DEF);
|
||||
setAudiencePlayModel(selectClarity);
|
||||
} else {
|
||||
switchStream(srcUrl, selectClarity);
|
||||
}
|
||||
IMLoginManager.get(mContext).put(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, selectClarity);
|
||||
showToast();
|
||||
}
|
||||
|
||||
private void showToast() {
|
||||
DialogUitl.showToast(mContext, "設置成功\n" +
|
||||
"正在為你轉換中", 3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDismiss(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(BasePopupView popupView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickOutside(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
})
|
||||
.asCustom(liveClarityCustomPopup)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把观众转换成主播
|
||||
*/
|
||||
@@ -793,14 +901,15 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
for (RCRTCInputStream stream : data.getLiveStreams()) {
|
||||
if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
|
||||
//暂停播放
|
||||
mPlayer.stopPlay();
|
||||
mPlayer.stop();
|
||||
//如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
|
||||
|
||||
//如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
|
||||
RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
|
||||
((RCRTCVideoInputStream) stream).setVideoView(remoteView);
|
||||
//todo 本demo只演示添加1个远端用户的视图
|
||||
remoteView.setScalingType(SCALE_ASPECT_FILL);
|
||||
remoteView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
remoteView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
|
||||
ry_view.addView(remoteView);
|
||||
Log.e("ry", stream.getMediaType() + "rcrtcOtherRoom成功 :" + data.getLiveStreams().size());
|
||||
}
|
||||
@@ -962,6 +1071,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
if (userinputStreamList1.size() == 0) {
|
||||
//如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
|
||||
RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
|
||||
((RCRTCVideoInputStream) stream).setStreamType(RCRTCStreamType.NORMAL);
|
||||
((RCRTCVideoInputStream) stream).setVideoView(remoteView);
|
||||
((RCRTCVideoInputStream) stream).setVideoFrameListener(new IRCRTCVideoInputFrameListener() {
|
||||
@Override
|
||||
@@ -971,6 +1081,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
"timestampNs:" + videoFrame.getTimestampNs() + "\n" +
|
||||
"分辨率:" + videoFrame.getBuffer().getHeight() + "x" + videoFrame.getBuffer().getWidth() + "\n" +
|
||||
"当前时间:" + new SimpleDateFormat("HH:mm:ss", Locale.CHINA).format(new Date()) + "\n";
|
||||
Log.d("ry", "onFrame: " + debugText);
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
debugView.setText(debugText);
|
||||
|
||||
@@ -979,7 +1090,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
});
|
||||
//todo 本demo只演示添加1个远端用户的视图
|
||||
ry_view.removeAllViews();
|
||||
remoteView.setScalingType(SCALE_ASPECT_FILL);
|
||||
remoteView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
remoteView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
|
||||
ry_view.addView(remoteView);
|
||||
}
|
||||
userinputStreamList1.add(stream);
|
||||
@@ -1030,4 +1142,208 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoadViewListener(LoadingListener listener) {
|
||||
super.setLoadViewListener(listener);
|
||||
}
|
||||
|
||||
private void showLoadingDialog() {
|
||||
if (PLAY_MODEL == PLAY_MODEL_480) return;
|
||||
|
||||
new DialogUitl.Builder(mContext)
|
||||
.setTitle("網絡提示")
|
||||
.setContent("系統監測到您的網絡不穩定,對此將清晰度變成了流暢,您可以在側邊菜單中的「清晰度」選擇調回。")
|
||||
.setView(R.layout.dialog_simple_tip)
|
||||
.setClickCallback(new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).build().show();
|
||||
PLAY_MODEL = PLAY_MODEL_480;
|
||||
String url = srcUrl;
|
||||
if (videoLandscape == VIDEO_VERTICAL) {
|
||||
url = url.replace(".flv", videoRatioVertical[PLAY_MODEL_480] + videoFps[0] + ".flv");
|
||||
} else if (videoLandscape == VIDEO_HORIZONTAL) {
|
||||
url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL_480] + videoFps[0] + ".flv");
|
||||
}
|
||||
mPlayer.switchUrl(url);
|
||||
}
|
||||
|
||||
private class ExoPlayerListener implements Player.Listener {
|
||||
String TAG = "播放流";
|
||||
|
||||
@Override
|
||||
public void onPlayerError(PlaybackException error) {
|
||||
Player.Listener.super.onPlayerError(error);
|
||||
debugView.setText("播放出错code=" + error.errorCode + " msg=" + error.getErrorCodeName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoSizeChanged(VideoSize videoSize) {
|
||||
Player.Listener.super.onVideoSizeChanged(videoSize);
|
||||
Log.i(TAG, "onVideoSizeChanged: width = " + videoSize.width + " height = " + videoSize.height);
|
||||
//ToastUtil.show("分辨率: 宽 = " + videoSize.width + " 高 = " + videoSize.height);
|
||||
if (videoSize.height > videoSize.width) {
|
||||
videoLandscape = VIDEO_VERTICAL;
|
||||
} else {
|
||||
videoLandscape = VIDEO_HORIZONTAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackStateChanged(int playbackState) {
|
||||
Player.Listener.super.onPlaybackStateChanged(playbackState);
|
||||
if (playbackState == Player.STATE_BUFFERING) {
|
||||
//showLoadingDialog();
|
||||
OkDownload.getInstance().pauseAll();
|
||||
Log.i(TAG, "onPlaybackStateChanged: 缓存中");
|
||||
} else {
|
||||
Log.i(TAG, "onPlaybackStateChanged: 播放中");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIsPlayingChanged(boolean isPlaying) {
|
||||
Player.Listener.super.onIsPlayingChanged(isPlaying);
|
||||
if (isPlaying) {
|
||||
hideCover();
|
||||
Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = " + waitNextUrl);
|
||||
OkDownload.getInstance().startAll();
|
||||
if (loadingListener != null) {
|
||||
loadingListener.onPlayer();
|
||||
}
|
||||
if (waitNextUrl != null) {
|
||||
mPlayer.switchUrl(waitNextUrl);
|
||||
waitNextUrl = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private int mPkTimeCount = 0;
|
||||
private Handler countdownHandler = new Handler();
|
||||
private View detailsView = null;
|
||||
private FrameLayout timeTitle;
|
||||
private TextView textTime;
|
||||
private TextView textPkName1, textPkName2, textPkName3, textPkName4;
|
||||
private TextView textGrade1, textGrade2, textGrade3, textGrade4;
|
||||
private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
|
||||
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
|
||||
|
||||
/**
|
||||
* PK倒计时
|
||||
*/
|
||||
public void upDataPkScore(JSONArray pkScores, int time) {
|
||||
|
||||
if (detailsView == null) {
|
||||
detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
|
||||
timeTitle = detailsView.findViewById(R.id.time_title);
|
||||
textTime = detailsView.findViewById(R.id.text_time);
|
||||
linearGrade1 = detailsView.findViewById(R.id.lin_pk1);
|
||||
linearGrade2 = detailsView.findViewById(R.id.lin_pk2);
|
||||
linearGrade3 = detailsView.findViewById(R.id.lin_pk3);
|
||||
linearGrade4 = detailsView.findViewById(R.id.lin_pk4);
|
||||
textPkName1 = detailsView.findViewById(R.id.text_pk_name1);
|
||||
textPkName2 = detailsView.findViewById(R.id.text_pk_name2);
|
||||
textPkName3 = detailsView.findViewById(R.id.text_pk_name3);
|
||||
textPkName4 = detailsView.findViewById(R.id.text_pk_name4);
|
||||
textGrade1 = detailsView.findViewById(R.id.text_grade1);
|
||||
textGrade2 = detailsView.findViewById(R.id.text_grade2);
|
||||
textGrade3 = detailsView.findViewById(R.id.text_grade3);
|
||||
textGrade4 = detailsView.findViewById(R.id.text_grade4);
|
||||
imageGrade1 = detailsView.findViewById(R.id.image_grade1);
|
||||
imageGrade2 = detailsView.findViewById(R.id.image_grade2);
|
||||
imageGrade3 = detailsView.findViewById(R.id.image_grade3);
|
||||
imageGrade4 = detailsView.findViewById(R.id.image_grade4);
|
||||
linearGrade1.setVisibility(View.GONE);
|
||||
linearGrade2.setVisibility(View.GONE);
|
||||
linearGrade3.setVisibility(View.GONE);
|
||||
linearGrade4.setVisibility(View.GONE);
|
||||
mVideoView.addView(detailsView);
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < pkScores.size(); i++) {
|
||||
JSONObject score = pkScores.getJSONObject(i);
|
||||
String userNiceName = score.getString("user_nicename");
|
||||
long userScore = score.getLong("score");
|
||||
int resScore = R.mipmap.icon_livepk_no1;
|
||||
if (userScore == 0 && !score.containsKey("paiming")) {
|
||||
resScore = R.mipmap.icon_livepk_no1;
|
||||
} else {
|
||||
if (score.containsKey("paiming")) {
|
||||
int ranking = score.getIntValue("paiming");
|
||||
switch (ranking) {
|
||||
case 1:
|
||||
resScore = R.mipmap.icon_livepk_no1;
|
||||
break;
|
||||
case 2:
|
||||
resScore = R.mipmap.icon_livepk_no2;
|
||||
break;
|
||||
case 3:
|
||||
resScore = R.mipmap.icon_livepk_no3;
|
||||
break;
|
||||
case 4:
|
||||
resScore = R.mipmap.icon_livepk_no4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
linearGrade1.setVisibility(View.VISIBLE);
|
||||
textPkName1.setText(userNiceName);
|
||||
ImgLoader.display(mContext, resScore, imageGrade1);
|
||||
textGrade1.setText(String.valueOf(userScore));
|
||||
} else if (i == 1) {
|
||||
linearGrade2.setVisibility(View.VISIBLE);
|
||||
textPkName2.setText(userNiceName);
|
||||
ImgLoader.display(mContext, resScore, imageGrade2);
|
||||
textGrade2.setText(String.valueOf(userScore));
|
||||
} else if (i == 2) {
|
||||
linearGrade4.setVisibility(View.VISIBLE);
|
||||
textPkName4.setText(userNiceName);
|
||||
ImgLoader.display(mContext, resScore, imageGrade4);
|
||||
textGrade4.setText(String.valueOf(userScore));
|
||||
} else if (i == 3) {
|
||||
linearGrade3.setVisibility(View.VISIBLE);
|
||||
textPkName3.setText(userNiceName);
|
||||
ImgLoader.display(mContext, resScore, imageGrade3);
|
||||
textGrade3.setText(String.valueOf(userScore));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (time > 0) {
|
||||
mPkTimeCount = time;
|
||||
timeTitle.setVisibility(View.VISIBLE);
|
||||
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Runnable countdownRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mPkTimeCount--;
|
||||
if (mPkTimeCount > 0) {//
|
||||
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
|
||||
textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
|
||||
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
|
||||
} else {
|
||||
timeTitle.setVisibility(View.GONE);
|
||||
countdownHandler.removeCallbacks(countdownRunnable);
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取下一秒钟的时间
|
||||
*/
|
||||
private long getNextSecondTime() {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
return now + (1000 - now % 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXL
|
||||
* @param url 流地址
|
||||
*/
|
||||
@Override
|
||||
public void play(String url) {
|
||||
public void play(String url,int playModel) {
|
||||
url = "webrtc://5664.liveplay.myqcloud.com/live/5664_harchar1";
|
||||
|
||||
mPlayer = new V2TXLivePlayerImpl(mContext);
|
||||
@@ -318,6 +318,11 @@ public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXL
|
||||
L.e(TAG, "play----url--->" + url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchStream(String url, int playModel) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopPlay() {
|
||||
mChangeToLeft = false;
|
||||
|
||||
@@ -251,7 +251,7 @@ public class LivePlayTxViewHolder_backup extends LiveRoomPlayViewHolder implemen
|
||||
* @param url 流地址
|
||||
*/
|
||||
@Override
|
||||
public void play(String url) {
|
||||
public void play(String url,int playModel) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
@@ -280,6 +280,11 @@ public class LivePlayTxViewHolder_backup extends LiveRoomPlayViewHolder implemen
|
||||
L.e(TAG, "play----url--->" + url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchStream(String url, int playModel) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopPlay() {
|
||||
mChangeToLeft = false;
|
||||
|
||||
@@ -33,11 +33,16 @@ import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.event.AnchorInfoEvent;
|
||||
import com.yunbao.common.event.LivePushRyEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
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.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
@@ -53,6 +58,8 @@ import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
|
||||
import com.yunbao.live.socket.SocketSendBean;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -95,15 +102,37 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
public TencentTRTCBeautyManager tencentTRTCBeautyManager;
|
||||
public static Context contexts;
|
||||
public static TextView btn_close;
|
||||
public static LinearLayout dr_pk_view;
|
||||
public LinearLayout dr_pk_view;
|
||||
public static RCRTCRoom rtcRoom;
|
||||
public static RCRTCLiveInfo rcrtcLiveInfo;
|
||||
|
||||
private ViewGroup liveActivityContainer;
|
||||
public FrameLayout timeTitle;
|
||||
public TextView textTime;
|
||||
private TextView tv_avatarOther_name;
|
||||
private ImageView avatarOther;
|
||||
private LinearLayout goto_room_view;
|
||||
|
||||
//修改上面主播的头像
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onUPAnchorInfo(AnchorInfoEvent e) {
|
||||
if (e != null) {
|
||||
if (e.isClear() == false) {
|
||||
tv_avatarOther_name.setText(e.getUserNiceName());
|
||||
ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther);
|
||||
goto_room_view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
goto_room_view.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LivePushRyViewHolder(Context context, ViewGroup parentView) {
|
||||
super(context, parentView);
|
||||
this.contexts = context;
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,6 +343,8 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
userBean1.setUserNiceName("null");
|
||||
userBean1.setAvatar("null");
|
||||
}
|
||||
mLiveRyLinkMicPkPresenter.onLinkMicToPk(userBean1);
|
||||
mLiveRyLinkMicPkPresenter.onLinkMicPkStart(inviteeRoomId, 3);
|
||||
//单人PK,减掉次数
|
||||
if (!RandomPkManager.getInstance().isRandomModel()) {
|
||||
LiveNetManager.get(mContext).setFreePkNum(new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@@ -369,16 +400,26 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
Bus.getOn(this);
|
||||
mPreView = (FrameLayout) findViewById(R.id.camera_preview);
|
||||
camera = (LinearLayout) findViewById(R.id.camera);
|
||||
mPreView1 = (FrameLayout) findViewById(R.id.camera_preview1);
|
||||
cameraPreview3 = (FrameLayout) findViewById(R.id.camera_preview3);
|
||||
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);
|
||||
leave = (ImageView) findViewById(R.id.leave);
|
||||
dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
|
||||
timeTitle = (FrameLayout) findViewById(R.id.time_title);
|
||||
textTime = (TextView) findViewById(R.id.text_time);
|
||||
dr_pk_view.setVisibility(View.GONE);
|
||||
cameraPreview3.setVisibility(View.GONE);
|
||||
btn_close = (TextView) findViewById(R.id.btn_close);
|
||||
tv_avatarOther_name = (TextView) findViewById(R.id.tv_avatarOther_name);
|
||||
avatarOther = (ImageView) findViewById(R.id.avatarOther);
|
||||
goto_room_view = (LinearLayout) findViewById(R.id.goto_room_view);
|
||||
goto_room_view.setVisibility(View.GONE);
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
btn_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -387,7 +428,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
//断开连麦
|
||||
LiveRyAnchorActivity.isDRPK=0;
|
||||
LiveRyAnchorActivity.isDRPK = 0;
|
||||
HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout")
|
||||
.execute(new HttpCallback() {
|
||||
@Override
|
||||
@@ -418,6 +459,10 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
mPreView1.setVisibility(View.GONE);
|
||||
inputStreamList.clear();
|
||||
inputStreamList1.clear();
|
||||
changeToBig();
|
||||
//清理PK上面对方的头像
|
||||
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
|
||||
closeButtonGone();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -530,16 +575,37 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
|
||||
RCRTCEngine.getInstance().init(contexts, config);
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM);
|
||||
//設置開播分辨率
|
||||
RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||
int minRate = 200;
|
||||
int maxRate = 900;
|
||||
switch (IMLoginManager.get(mContext).getSelectClarity()) {
|
||||
case 0:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||
minRate = 200;
|
||||
maxRate = 900;
|
||||
break;
|
||||
case 1:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
|
||||
minRate = 250;
|
||||
maxRate = 2200;
|
||||
break;
|
||||
case 2:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
|
||||
minRate = 400;
|
||||
maxRate = 4000;
|
||||
break;
|
||||
}
|
||||
|
||||
RCRTCVideoStreamConfig videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create()
|
||||
//设置分辨率
|
||||
.setVideoResolution(RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_640)
|
||||
.setVideoResolution(rcrtcVideoResolution)
|
||||
//设置帧率
|
||||
.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_30)
|
||||
.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_24)
|
||||
//设置最小码率,480P下推荐200
|
||||
.setMinRate(250)
|
||||
.setMinRate(minRate)
|
||||
//设置最大码率,480P下推荐900
|
||||
.setMaxRate(5000)
|
||||
.setMaxRate(maxRate)
|
||||
.build();
|
||||
|
||||
// 创建本地视频显示视图
|
||||
@@ -565,7 +631,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
mPreView.addView(rongRTCVideoView);
|
||||
tencentTRTCBeautyManager = new TencentTRTCBeautyManager(mContext);
|
||||
|
||||
|
||||
//加入房间成功后可以通过 RCRTCLocalUser 对象发布本地默认音视频流,包括:麦克风采集的音频和摄像头采集的视频。
|
||||
RCRTCEngine.getInstance().getDefaultVideoStream().setEncoderMirror(true);
|
||||
if (rtcRoom == null || rtcRoom.getLocalUser() == null) {
|
||||
@@ -585,20 +650,13 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
room.registerRoomListener(roomEventsListener);
|
||||
|
||||
//美颜
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
public void run() {
|
||||
//旧美颜不需要了
|
||||
/*RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(new IRCRTCVideoOutputFrameListener() {
|
||||
@Override
|
||||
public RCRTCVideoFrame processVideoFrame(RCRTCVideoFrame rtcVideoFrame) {
|
||||
// 使用数据进行美颜/录像等处理后,需要把数据再返回给 SDK 做发送。
|
||||
rtcVideoFrame.setTextureId(tencentTRTCBeautyManager.renderWithTexture(rtcVideoFrame.getTextureId(), rtcVideoFrame.getWidth(), rtcVideoFrame.getHeight(), false));
|
||||
return rtcVideoFrame;
|
||||
}
|
||||
});*/
|
||||
|
||||
}
|
||||
});
|
||||
// new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
// public void run() {
|
||||
// //旧美颜不需要了
|
||||
//
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -623,19 +681,29 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
params.width = mPreView.getWidth() / 2;
|
||||
params.height = DpUtil.dp2px(250);
|
||||
params.topMargin = DpUtil.dp2px(130);
|
||||
mPreView.setLayoutParams(params);
|
||||
camera.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeToBig() {
|
||||
if (mPreView != null) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mPreView.getLayoutParams();
|
||||
if (camera != null) {
|
||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) camera.getLayoutParams();
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.topMargin = 0;
|
||||
mPreView.setLayoutParams(params);
|
||||
camera.setLayoutParams(params);
|
||||
}
|
||||
if (mPreView1.getVisibility() == View.VISIBLE) {
|
||||
mPreView1.removeAllViews();
|
||||
mPreView1.setVisibility(View.GONE);
|
||||
inputStreamList.clear();
|
||||
inputStreamList1.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeButtonGone() {
|
||||
btn_close.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -686,24 +754,38 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
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;
|
||||
|
||||
//推荐宽、高、帧率参数值可以通过默认视频流的配置获取,也可以根据实际需求来自定义设置
|
||||
//如不设置宽高值则服务端将使用默认宽高 360 * 640
|
||||
//例:发布的视频分辨率为720 * 1280,如果不设置则观众端看到的视频分辨率为 360 * 640,
|
||||
//所以如果想让观众端看到的视频分辨率和发布视频分辨率一致,则应从发布的视频流中获取分辨率配置并设置到 mediaConfig 中
|
||||
//設置開播分辨率
|
||||
//設置開播分辨率
|
||||
RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||
int minRate = 200;
|
||||
int maxRate = 900;
|
||||
switch (IMLoginManager.get(mContext).getSelectClarity()) {
|
||||
case 0:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||
break;
|
||||
case 1:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
|
||||
break;
|
||||
case 2:
|
||||
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
|
||||
break;
|
||||
}
|
||||
int width = rcrtcVideoResolution.getWidth();
|
||||
int height = rcrtcVideoResolution.getHeight();
|
||||
normal.setWidth(width); //视频宽
|
||||
normal.setHeight(height); //视频高
|
||||
normal.setFps(fps); //视频帧率
|
||||
|
||||
normal.setFps(15); //视频帧率
|
||||
videoConfig.setVideoLayout(normal);
|
||||
//2. 合流画布设置
|
||||
//(请参照画布和声音配置示例代码)
|
||||
//3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准),设置每个视频流小窗口的坐标及宽高
|
||||
@@ -732,6 +814,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -788,6 +871,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
@Override
|
||||
public void release() {
|
||||
super.release();
|
||||
Bus.getOff(this);
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
|
||||
rtcRoom = null;
|
||||
}
|
||||
@@ -843,4 +927,19 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
return ((LiveActivity) mContext).getTxAppId();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void setSelectClarity(LivePushRyEvent event) {
|
||||
if (rtcRoom != null)
|
||||
rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback<RCRTCLiveInfo>() {
|
||||
@Override
|
||||
public void onSuccess(RCRTCLiveInfo rcrtcLiveInfo1) {
|
||||
rcrtcLiveInfo = rcrtcLiveInfo1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(RTCErrorCode rtcErrorCode) {
|
||||
Log.e("ry", "rtcErrorCode" + rtcErrorCode);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.activity.LiveChooseClassActivity;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.adapter.LiveReadyShareAdapter;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveTimeDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveWishListDialogFragment;
|
||||
@@ -471,7 +471,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
|
||||
return;
|
||||
}
|
||||
String title = mEditTitle.getText().toString().trim();
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, new HttpCallback() {
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile,0, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, final String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.yunbao.live.views;
|
||||
|
||||
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.live.views.LivePushTxViewHolder.mTRTCCloud;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -17,12 +18,17 @@ import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSendCallback;
|
||||
import com.tencent.trtc.TRTCCloudDef;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
@@ -42,7 +48,6 @@ import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.activity.LiveAnchorActivity;
|
||||
import com.yunbao.live.activity.LiveChooseClassActivity;
|
||||
import com.yunbao.live.adapter.LiveReadyShareAdapter;
|
||||
import com.yunbao.live.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveTimeDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveWishListDialogFragment;
|
||||
@@ -51,10 +56,6 @@ import com.yunbao.live.http.LiveHttpUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
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.live.views.LivePushTxViewHolder.mTRTCCloud;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/7.
|
||||
* 开播前准备
|
||||
@@ -491,7 +492,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
|
||||
return;
|
||||
}
|
||||
String title = mEditTitle.getText().toString().trim();
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, new HttpCallback() {
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, 0, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, final String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
@@ -535,7 +536,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
|
||||
@Override
|
||||
public void onError(Response<JsonBean> response) {
|
||||
super.onError(response);
|
||||
System.out.println("tx 开播失败 = "+response);
|
||||
System.out.println("tx 开播失败 = " + response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ package com.yunbao.live.views;
|
||||
import android.content.Context;
|
||||
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.utils.ToastUtil;
|
||||
import com.yunbao.common.views.AbsViewHolder;
|
||||
import com.yunbao.live.interfaces.ILiveLinkMicViewHolder;
|
||||
|
||||
@@ -13,14 +16,37 @@ import com.yunbao.live.interfaces.ILiveLinkMicViewHolder;
|
||||
|
||||
public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements ILiveLinkMicViewHolder {
|
||||
protected LiveBean mLiveBean;
|
||||
public static final String PLAY_MODEL_KEY = "user_audience_play_model";
|
||||
public static final int PLAY_MODEL_DEF = -1;
|
||||
public static final int PLAY_MODEL_480 = 0;
|
||||
public static final int PLAY_MODEL_720 = 1;
|
||||
public static final int PLAY_MODEL_1080 = 2;
|
||||
public static int PLAY_MODEL_ANCHOR = -1;//主播设置的最高画质
|
||||
public static int PLAY_MODEL = PLAY_MODEL_DEF;
|
||||
|
||||
public static final String[] videoRatioHorizontal = new String[]{"_640_480", "_960_720", "_1440_1080"};
|
||||
public static final String[] videoRatioVertical = new String[]{"_480_848", "_720_1280", "_1080_1920"};
|
||||
public static final String[] videoFps = new String[]{"_24", "_30"};
|
||||
OnMicCallback onMicCallback;//连麦回调
|
||||
public EnterRoomNewModel roomModel;
|
||||
LoadingListener loadingListener;
|
||||
|
||||
public LiveRoomPlayViewHolder(Context context, ViewGroup parentView) {
|
||||
super(context, parentView);
|
||||
}
|
||||
|
||||
public abstract void play(String url);
|
||||
public void setAnchorPlayModel(int model) {
|
||||
PLAY_MODEL_ANCHOR = model;
|
||||
}
|
||||
|
||||
public void setAudiencePlayModel(int model) {
|
||||
PLAY_MODEL = model;
|
||||
}
|
||||
|
||||
|
||||
public abstract void play(String url, int playModel);
|
||||
|
||||
public abstract void switchStream(String url, int playModel);
|
||||
|
||||
public abstract void stopPlay();
|
||||
|
||||
@@ -50,6 +76,9 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
|
||||
this.mLiveBean = data;
|
||||
}
|
||||
|
||||
public void setViewUP(int i) {
|
||||
}
|
||||
|
||||
public OnMicCallback getOnMicCallback() {
|
||||
return onMicCallback;
|
||||
}
|
||||
@@ -58,9 +87,28 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
|
||||
this.onMicCallback = onMicCallback;
|
||||
}
|
||||
|
||||
public void setLiveEnterRoomNewModel(EnterRoomNewModel data) {
|
||||
this.roomModel = data;
|
||||
}
|
||||
|
||||
public interface OnMicCallback{
|
||||
public void setLoadViewListener(LoadingListener listener) {
|
||||
this.loadingListener = listener;
|
||||
}
|
||||
|
||||
public void switchStreamPk(boolean isPk) {
|
||||
}
|
||||
|
||||
public void clearFrame() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface OnMicCallback {
|
||||
void onMikUpdate();
|
||||
|
||||
}
|
||||
|
||||
public interface LoadingListener {
|
||||
void onPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,16 +448,26 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
|
||||
time.setText("PK時間:" + s1);
|
||||
mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME, getNextSecondTime());
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).setPkStatus(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
time.setVisibility(View.GONE);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).setPkStatus(false);
|
||||
}
|
||||
endDRGif();
|
||||
}
|
||||
}
|
||||
|
||||
public void hotAddVisibility(boolean visibility) {
|
||||
ft_hot_add.setVisibility(visibility ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
public void endDRGif() {
|
||||
if (dr_pk_end_gif.getVisibility() == View.GONE) {
|
||||
dr_pk_end_gif.setImageResource(R.mipmap.drpkend);
|
||||
@@ -869,54 +879,56 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
mChatRecyclerView.setLayoutParams(params1);
|
||||
|
||||
mChatRecyclerView.setHasFixedSize(true);
|
||||
LinearLayoutManager layoutManager = new LiveChatRecyclerViewLayoutManager(mContext);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
|
||||
layoutManager.setOrientation(RecyclerView.VERTICAL);
|
||||
// layoutManager.setReverseLayout(true);
|
||||
layoutManager.setStackFromEnd(true);
|
||||
mChatRecyclerView.setLayoutManager(layoutManager);
|
||||
mChatRecyclerView.addItemDecoration(new TopGradual());
|
||||
mChatRecyclerView.setItemViewCacheSize(10);
|
||||
mChatRecyclerView.setItemAnimator(new SimpleItemAnimator() {
|
||||
@Override
|
||||
public boolean animateRemove(RecyclerView.ViewHolder holder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean animateAdd(RecyclerView.ViewHolder holder) {
|
||||
Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.live_chat_msg_in);
|
||||
holder.itemView.startAnimation(animation);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean animateMove(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runPendingAnimations() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endAnimation(@NonNull RecyclerView.ViewHolder item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endAnimations() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
// mChatRecyclerView.setItemAnimator(new SimpleItemAnimator() {
|
||||
// @Override
|
||||
// public boolean animateRemove(RecyclerView.ViewHolder holder) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean animateAdd(RecyclerView.ViewHolder holder) {
|
||||
// Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.live_chat_msg_in);
|
||||
// holder.itemView.startAnimation(animation);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean animateMove(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void runPendingAnimations() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void endAnimation(@NonNull RecyclerView.ViewHolder item) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void endAnimations() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isRunning() {
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
mLiveChatAdapter = new LiveChatAdapter(mContext);
|
||||
mChatRecyclerView.setAdapter(mLiveChatAdapter);
|
||||
mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() {
|
||||
@@ -1199,6 +1211,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
mRedVal.setVisibility(View.GONE);
|
||||
mBlueVal.setVisibility(View.GONE);
|
||||
mPkRankTopIcon.setVisibility(View.GONE);
|
||||
mAnchorLayout.setBackgroundResource(R.drawable.bg_live_ico);
|
||||
mGoodNumberIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3893,6 +3907,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
mLiveChatAdapter.insertItem(bean);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 幸运100%活动
|
||||
*/
|
||||
public void lucky100(MsgModel model){
|
||||
if (mLiveChatAdapter != null) {
|
||||
LiveChatBean bean = new LiveChatBean();
|
||||
bean.setType(LiveChatBean.LUCKY_100_CHECK);
|
||||
bean.setMsgModel(model);
|
||||
mLiveChatAdapter.insertItem(bean);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void updateSub(LiveAudienceEvent event) {
|
||||
@@ -3915,7 +3940,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
customFullServiceNotify(event.getCustomFullServiceNotifyEvent());
|
||||
break;
|
||||
case PK_TIME_COUNT:
|
||||
endDRGif();
|
||||
// endDRGif();
|
||||
break;
|
||||
case UP_PK_TWO:
|
||||
pkUid = (String) event.getObject();
|
||||
|
||||
@@ -5,7 +5,6 @@ import static com.yunbao.live.activity.LiveRyAnchorActivity.PKing;
|
||||
import static com.yunbao.live.activity.LiveRyAnchorActivity.pk_nub;
|
||||
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.START_MESSAGE;
|
||||
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
|
||||
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -149,7 +148,8 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
|
||||
.execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
leaveDRRoom();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM));
|
||||
PKing = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
@@ -129,7 +130,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
//侧滑布局
|
||||
// private DrawerLayout drawerLayout;
|
||||
//直播间拆分布局
|
||||
private LiveRoomPlayViewHolder mLivePlayViewHolder;
|
||||
private LivePlayRyViewHolder mLivePlayViewHolder;
|
||||
//头部布局
|
||||
public LiveRoomViewHolder mLiveRoomViewHolder;
|
||||
//底部布局
|
||||
@@ -186,6 +187,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
|
||||
private int landscape;
|
||||
private String leaveStream = "", leaveGroupId = "";
|
||||
public static PortraitLiveManager portraitLiveManager;
|
||||
|
||||
|
||||
public PortraitLiveManager setQuitF(boolean quitF) {
|
||||
isQuitF = quitF;
|
||||
@@ -196,6 +199,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
this.mContext = context;
|
||||
this.mIntent = intent;
|
||||
liveImDeletUtil = new LiveImDeletUtil();
|
||||
portraitLiveManager = this;
|
||||
ininView();
|
||||
}
|
||||
|
||||
@@ -241,12 +245,22 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mViewPager.setCanScroll(true);
|
||||
}
|
||||
};
|
||||
final Runnable loadRunnableGone = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) {
|
||||
isEnterRoom = false;
|
||||
openParametersModel = new OpenParametersModel();
|
||||
if(mLiveRoomViewHolder!=null){
|
||||
mLiveRoomViewHolder.UpPkTwo();
|
||||
}
|
||||
mContext.runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Log.e("ImgLoader1", data.getAvatar());
|
||||
@@ -264,6 +278,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), ivBg);
|
||||
AnimationDrawable frameAnimation = (AnimationDrawable) ivLoading.getBackground();
|
||||
frameAnimation.start();
|
||||
liveHandler.removeCallbacks(loadRunnableGone);
|
||||
if (mLivePlayViewHolder == null) {
|
||||
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
|
||||
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager());
|
||||
@@ -273,6 +288,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
|
||||
mLivePlayViewHolder.addToParent();
|
||||
mLivePlayViewHolder.subscribeActivityLifeCycle();
|
||||
mLivePlayViewHolder.setLoadViewListener(new LiveRoomPlayViewHolder.LoadingListener() {
|
||||
@Override
|
||||
public void onPlayer() {
|
||||
liveHandler.postDelayed(loadRunnableGone, 350);
|
||||
}
|
||||
});
|
||||
mLiveRoomViewHolder.subscribeActivityLifeCycle();
|
||||
mLiveAudienceViewHolder.addToParent();
|
||||
mLiveRoomViewHolder.addToParent();
|
||||
@@ -282,6 +303,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveLinkMicPresenter.setLiveSdk(mLiveSDK);
|
||||
mLiveLinkMicAnchorPresenter.setLiveSdk(mLiveSDK);
|
||||
}
|
||||
if (mLiveRyLinkMicPkPresenter == null) {
|
||||
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
|
||||
}
|
||||
//去除主播离开画面
|
||||
if (LivePlayKsyViewHolder.leave != null) {
|
||||
LivePlayKsyViewHolder.leave.setVisibility(View.GONE);
|
||||
@@ -294,9 +318,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600);
|
||||
|
||||
mask.setVisibility(View.VISIBLE);
|
||||
mLivePlayViewHolder.clearFrame();
|
||||
mLivePlayViewHolder.setLiveBean(mLiveBean);
|
||||
mLivePlayViewHolder.removeDetailView();
|
||||
mLivePlayViewHolder.setCover(mLiveBean.getAvatar());
|
||||
mLivePlayViewHolder.play(mLiveBean.getPull());
|
||||
mLivePlayViewHolder.setLiveBeanLandscape(mLiveBean.getLandscape());
|
||||
//mLivePlayViewHolder.play(mLiveBean.getPull(), LiveRoomPlayViewHolder.PLAY_MODEL_DEF);
|
||||
mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() {
|
||||
@Override
|
||||
public void onMikUpdate() {
|
||||
@@ -327,6 +354,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Runnable sendFIm = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -352,6 +380,16 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
}
|
||||
landscape = data.getLiveInfo().getLandscape();
|
||||
mLivePlayViewHolder.setLiveBeanLandscape(landscape);
|
||||
mLivePlayViewHolder.setLiveEnterRoomNewModel(data);
|
||||
mLivePlayViewHolder.clearFrame();
|
||||
int userClarityType = IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, -1);
|
||||
int anchorClarityType = data.getClarityType() - 1;
|
||||
if (userClarityType != anchorClarityType) {
|
||||
mLivePlayViewHolder.play(mLiveBean.getPull(), userClarityType);
|
||||
} else {
|
||||
mLivePlayViewHolder.play(mLiveBean.getPull(), LiveRoomPlayViewHolder.PLAY_MODEL_DEF);
|
||||
}
|
||||
mLivePlayViewHolder.setAnchorPlayModel(anchorClarityType);
|
||||
//是否热度卡加成
|
||||
liveHandler.postDelayed(() -> mLiveRoomViewHolder.getIsHot(data.getIsUseHotCard()), 700);
|
||||
|
||||
@@ -486,17 +524,17 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
}
|
||||
}
|
||||
|
||||
if (data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) {
|
||||
if (mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) {
|
||||
|
||||
LivePlayRyViewHolder.setViewUP(1);
|
||||
mLivePlayViewHolder.setViewUP(1);
|
||||
|
||||
}
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.pkHandler = false;
|
||||
}
|
||||
if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了
|
||||
if (mLivePlayViewHolder != null && pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了
|
||||
|
||||
LivePlayRyViewHolder.setViewUP(2);
|
||||
mLivePlayViewHolder.setViewUP(2);
|
||||
|
||||
//pk排名数据
|
||||
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
|
||||
@@ -520,7 +558,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRoomViewHolder.pkHandler = true;
|
||||
mLiveRoomViewHolder.initPkRank(null);
|
||||
}
|
||||
LivePlayRyViewHolder.setViewUP(3);
|
||||
if (mLivePlayViewHolder != null) {
|
||||
mLivePlayViewHolder.setViewUP(3);
|
||||
}
|
||||
|
||||
//pk排名数据
|
||||
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
|
||||
@@ -535,9 +575,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.initPkRank(null);
|
||||
}
|
||||
LivePlayRyViewHolder.setViewUP(4);
|
||||
if (mLivePlayViewHolder != null) {
|
||||
mLivePlayViewHolder.setViewUP(4);
|
||||
}
|
||||
|
||||
mLiveRoomViewHolder.UpPkBar(pkInfo.getJSONArray("userlist"), mLiveBean.getUid(), pkInfo.getIntValue("drpk_time"));
|
||||
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
|
||||
}
|
||||
//守护相关
|
||||
mLiveGuardInfo = new LiveGuardInfo();
|
||||
@@ -569,7 +611,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel));
|
||||
}
|
||||
}
|
||||
liveHandler.postDelayed(() -> loading.setVisibility(View.GONE), 700);
|
||||
liveHandler.postDelayed(loadRunnableGone, 15_000);
|
||||
|
||||
}
|
||||
|
||||
@@ -587,8 +629,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
|
||||
|
||||
public void removeLiveEnd() {
|
||||
if (mLiveEndViewHolder != null) {
|
||||
mLiveEndViewHolder.removeFromParent();
|
||||
mLiveEndViewHolder.release();
|
||||
}
|
||||
mLiveEndViewHolder = null;
|
||||
if (mLiveAudienceViewHolder != null) {
|
||||
|
||||
mLiveAudienceViewHolder.removeFromParent();
|
||||
mLiveAudienceViewHolder.removeCallbacks();
|
||||
mLiveAudienceViewHolder.release();
|
||||
@@ -604,17 +650,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRoomViewHolder.clearData();
|
||||
mLiveRoomViewHolder.countDownTimerTrickery = null;
|
||||
}
|
||||
if (mLiveEndViewHolder != null) {
|
||||
mLiveEndViewHolder.removeFromParent();
|
||||
mLiveEndViewHolder.release();
|
||||
}
|
||||
mLiveEndViewHolder = null;
|
||||
mLiveAudienceViewHolder = null;
|
||||
mLivePlayViewHolder = null;
|
||||
mLiveRoomViewHolder = null;
|
||||
mLiveLinkMicPresenter = null;
|
||||
mLiveLinkMicAnchorPresenter = null;
|
||||
mLiveRyLinkMicPkPresenter = null;
|
||||
mLivePlayViewHolder = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -633,19 +674,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
if (mLiveAudienceViewHolder != null) {
|
||||
mLiveAudienceViewHolder.removeCallbacks();
|
||||
}
|
||||
|
||||
//断开socket
|
||||
|
||||
if (mSocketRyClient != null) {
|
||||
mSocketRyClient.disConnect();
|
||||
mSocketRyClient = null;
|
||||
}
|
||||
|
||||
if (mSocketClient != null) {
|
||||
mSocketClient.disConnect();
|
||||
mSocketClient = null;
|
||||
}
|
||||
|
||||
if (mLiveLinkMicPresenter != null) {
|
||||
mLiveLinkMicPresenter.clearData();
|
||||
mLiveLinkMicPresenter.release();
|
||||
@@ -657,7 +694,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
if (mLiveRyLinkMicPkPresenter != null) {
|
||||
mLiveRyLinkMicPkPresenter.clearData();
|
||||
mLiveRyLinkMicPkPresenter.release();
|
||||
mLiveRyLinkMicPkPresenter = null;
|
||||
}
|
||||
if (mLiveEndViewHolder != null) {
|
||||
removeLiveEnd();
|
||||
}
|
||||
|
||||
if (isQuit) {
|
||||
isQuitF = true;
|
||||
if (mLiveAudienceViewHolder != null) {
|
||||
@@ -676,11 +718,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRoomViewHolder.clearData();
|
||||
mLiveRoomViewHolder.countDownTimerTrickery = null;
|
||||
}
|
||||
if (mLiveEndViewHolder != null) {
|
||||
mLiveEndViewHolder.removeFromParent();
|
||||
mLiveEndViewHolder.release();
|
||||
}
|
||||
mLiveEndViewHolder = null;
|
||||
|
||||
mLiveAudienceViewHolder = null;
|
||||
mLivePlayViewHolder = null;
|
||||
mLiveRoomViewHolder = null;
|
||||
@@ -1088,8 +1126,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
public void onKick(String touid) {
|
||||
if (!TextUtils.isEmpty(touid) && touid.equals(CommonAppConfig.getInstance().getUid())) {//被踢的是自己
|
||||
kick = true;
|
||||
exitLiveRoom(true);
|
||||
ToastUtil.show(WordUtil.getString(R.string.live_kicked_2));
|
||||
onRemove(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1263,6 +1301,21 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
if (mLivePlayViewHolder != null) {
|
||||
mLivePlayViewHolder.setLiveBeanLandscape(1);
|
||||
}
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).setPkStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pk状态
|
||||
*
|
||||
* @param isPk
|
||||
*/
|
||||
public void setPkStatus(boolean isPk) {
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.hotAddVisibility(isPk);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1277,6 +1330,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLivePlayViewHolder.setLiveBeanLandscape(landscape);
|
||||
}
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).setPkStatus(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1748,6 +1804,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 幸运100%活动
|
||||
*/
|
||||
public void lucky100(MsgModel model) {
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.lucky100(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void messageBottom() {
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.chatScrollToBottom();
|
||||
@@ -1758,6 +1823,31 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mViewPager.setCanScroll(enableScroll);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户端多人Pk
|
||||
*
|
||||
* @param pkScores
|
||||
* @param time
|
||||
*/
|
||||
public void upDataPkScore(JSONArray pkScores, int time) {
|
||||
if (mLivePlayViewHolder != null) {
|
||||
String liveId = mLiveBean.getUid();
|
||||
JSONObject liveModel = null;
|
||||
//调整数据
|
||||
int index = 0;
|
||||
for (int i = 0; i < pkScores.size(); i++) {
|
||||
JSONObject score = pkScores.getJSONObject(i);
|
||||
if (TextUtils.equals(score.getString("id"), liveId)) {
|
||||
liveModel = score;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
pkScores.remove(index);
|
||||
pkScores.add(0, liveModel);
|
||||
mLivePlayViewHolder.upDataPkScore(pkScores, time);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void endDRGif() {
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
|
||||
5
live/src/main/res/drawable/background_pk_time.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#60000000" />
|
||||
<corners android:radius="7.17dp" />
|
||||
</shape>
|
||||
252
live/src/main/res/layout/view_live_pk_details.xml
Normal file
@@ -0,0 +1,252 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<!--左上-->
|
||||
<LinearLayout
|
||||
android:id="@+id/lin_pk1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_grade1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5.33dp"
|
||||
android:layout_marginTop="4.67dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_grade1"
|
||||
android:layout_width="10.67dp"
|
||||
android:layout_height="10.67dp"
|
||||
android:layout_marginStart="2.67dp"
|
||||
android:layout_marginTop="1.67dp"
|
||||
android:layout_marginEnd="4.33dp"
|
||||
android:layout_marginBottom="1.67dp"
|
||||
android:src="@mipmap/icon_livepk_no1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_grade1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6.76dp"
|
||||
android:text="000"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_pk_name1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5.33dp"
|
||||
android:layout_marginTop="3.3dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="50dp"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingTop="4.33dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:paddingBottom="4.33dp"
|
||||
android:text="我方"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
</LinearLayout>
|
||||
<!--右上-->
|
||||
<LinearLayout
|
||||
android:id="@+id/lin_pk2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:gravity="end"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_grade2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4.67dp"
|
||||
android:layout_marginEnd="5.33dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_grade2"
|
||||
android:layout_width="10.67dp"
|
||||
android:layout_height="10.67dp"
|
||||
android:layout_marginStart="2.67dp"
|
||||
android:layout_marginTop="1.67dp"
|
||||
android:layout_marginEnd="4.33dp"
|
||||
android:layout_marginBottom="1.67dp"
|
||||
android:src="@mipmap/icon_livepk_no2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_grade2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6.76dp"
|
||||
android:text="000"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_pk_name2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3.3dp"
|
||||
android:layout_marginEnd="5.33dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="50dp"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingTop="4.33dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:paddingBottom="4.33dp"
|
||||
android:text="我方"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
</LinearLayout>
|
||||
<!--左下-->
|
||||
<LinearLayout
|
||||
android:id="@+id/lin_pk3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_pk_name3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5.33dp"
|
||||
android:layout_marginBottom="3.3dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="50dp"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingTop="4.33dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:paddingBottom="4.33dp"
|
||||
android:text="我方"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_grade3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5.33dp"
|
||||
android:layout_marginBottom="4.67dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_grade3"
|
||||
android:layout_width="10.67dp"
|
||||
android:layout_height="10.67dp"
|
||||
android:layout_marginStart="2.67dp"
|
||||
android:layout_marginTop="1.67dp"
|
||||
android:layout_marginEnd="4.33dp"
|
||||
android:layout_marginBottom="1.67dp"
|
||||
android:src="@mipmap/icon_livepk_no3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_grade3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6.76dp"
|
||||
android:text="000"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<!--右下-->
|
||||
<LinearLayout
|
||||
android:id="@+id/lin_pk4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:gravity="end"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_pk_name4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="5.33dp"
|
||||
android:layout_marginBottom="3.3dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="50dp"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingTop="4.33dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:paddingBottom="4.33dp"
|
||||
android:text="我方"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_grade4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="5.33dp"
|
||||
android:layout_marginBottom="4.67dp"
|
||||
android:background="@drawable/background_pk_time"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_grade4"
|
||||
android:layout_width="10.67dp"
|
||||
android:layout_height="10.67dp"
|
||||
android:layout_marginStart="2.67dp"
|
||||
android:layout_marginTop="1.67dp"
|
||||
android:layout_marginEnd="4.33dp"
|
||||
android:layout_marginBottom="1.67dp"
|
||||
android:src="@mipmap/icon_livepk_no3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_grade4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6.76dp"
|
||||
android:text="000"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<!--PK时间-->
|
||||
<FrameLayout
|
||||
android:id="@+id/time_title"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@mipmap/live_pk_time_bg"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/pk_time"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="10sp" />
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
@@ -7,9 +7,11 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<com.tencent.rtmp.ui.TXCloudVideoView
|
||||
<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" />
|
||||
|
||||
<ImageView
|
||||
|
||||
@@ -1,33 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/camera_preview"
|
||||
<LinearLayout
|
||||
android:id="@+id/camera"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/camera_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/camera_preview3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/camera_preview1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout android:id="@+id/dr_pk_view"
|
||||
<LinearLayout
|
||||
android:id="@+id/dr_pk_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@+id/camera_preview"
|
||||
android:layout_marginTop="130dp"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@@ -37,17 +53,17 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/dr1_preview"
|
||||
android:layout_width="100dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/live_icon_vacancy"/>
|
||||
android:layout_weight="1"
|
||||
android:background="@mipmap/live_icon_vacancy" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/dr2_preview"
|
||||
android:layout_width="100dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/live_icon_vacancy"/>
|
||||
android:layout_weight="1"
|
||||
android:background="@mipmap/live_icon_vacancy" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -59,24 +75,23 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/dr3_preview"
|
||||
android:layout_width="100dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@mipmap/live_icon_vacancy"/>
|
||||
android:background="@mipmap/live_icon_vacancy" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/dr4_preview"
|
||||
android:layout_width="100dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@mipmap/live_icon_vacancy"/>
|
||||
android:background="@mipmap/live_icon_vacancy" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
@@ -85,75 +100,110 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/layout_surface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<SurfaceView
|
||||
android:id="@+id/surface_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/goto_room_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="27dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="122dp"
|
||||
android:layout_marginRight="9dp"
|
||||
android:background="@drawable/bg_live_other_ico"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:gravity="center">
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/avatarOther"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/m_chu_xia"
|
||||
app:riv_oval="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_avatarOther_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="3dp"
|
||||
android:maxLength="4"
|
||||
android:maxLines="1"
|
||||
android:text=""
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/pk_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="270dp"
|
||||
android:layout_marginTop="130dp"
|
||||
>
|
||||
android:layout_marginTop="130dp">
|
||||
|
||||
<com.yunbao.live.custom.MyFrameLayout4
|
||||
android:id="@+id/left_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="20dp"
|
||||
/>
|
||||
android:layout_marginBottom="20dp" />
|
||||
|
||||
<com.yunbao.live.custom.MyFrameLayout4
|
||||
android:id="@+id/right_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginBottom="20dp"
|
||||
/>
|
||||
android:layout_marginBottom="20dp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="400dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="@drawable/background_dedede"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="結束連麥"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="13sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
||||
<com.yunbao.live.custom.MyFrameLayout3
|
||||
android:id="@+id/small_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="120dp"
|
||||
app:mfl3_ratio="0.25"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/btn_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:layout_marginTop="120dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="結束連麥"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@color/color_white"
|
||||
android:visibility="gone"
|
||||
android:background="@drawable/background_dedede"/>
|
||||
app:mfl3_ratio="0.25" />
|
||||
|
||||
|
||||
<ImageView
|
||||
@@ -161,7 +211,26 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@mipmap/zslk"
|
||||
android:visibility="gone"
|
||||
android:scaleType="centerCrop"/>
|
||||
android:visibility="gone" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/time_title"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="16.67dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@mipmap/live_pk_time_bg"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/pk_time"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp" />
|
||||
<!-- 详情-->
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/chat_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="370dp"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none" />
|
||||
@@ -707,8 +707,8 @@
|
||||
android:layout_height="27dp"
|
||||
android:layout_below="@id/live_time"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:visibility="gone">
|
||||
android:layout_marginTop="-12dp"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_hot_gif"
|
||||
@@ -1258,8 +1258,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon_pk_top"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_alignTop="@+id/live_video"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="40dp"
|
||||
@@ -1280,12 +1280,12 @@
|
||||
android:layout_marginStart="13dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/bg_live_item_pk_rank_red"
|
||||
android:paddingStart="17dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingEnd="17dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="15sp"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
@@ -1298,12 +1298,12 @@
|
||||
android:layout_marginEnd="13dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/bg_live_item_pk_rank_blue"
|
||||
android:paddingStart="17dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingEnd="17dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="15sp"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
@@ -2112,7 +2112,6 @@
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:src="@mipmap/voice" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -54,6 +54,43 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btn_live_clarity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_clarity"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@mipmap/icon_fhd" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/live_clarity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/high_definition"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="5dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@mipmap/icon_live_more" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btn_room_type"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -62,7 +99,7 @@
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/btn_live_clarity"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
@@ -94,11 +131,11 @@
|
||||
android:id="@+id/btn_live_class"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginStart="75dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_room_type"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_wishlist"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
|
||||
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 883 B |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 955 B |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
BIN
live/src/main/res/mipmap-xxxhdpi/icon_livepk_no1.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
live/src/main/res/mipmap-xxxhdpi/icon_livepk_no2.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
live/src/main/res/mipmap-xxxhdpi/icon_livepk_no3.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
live/src/main/res/mipmap-xxxhdpi/icon_livepk_no4.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |