|
@@ -0,0 +1,2360 @@
|
|
|
+package com.daya.tclive.ui;
|
|
|
+
|
|
|
+import android.Manifest;
|
|
|
+import android.animation.ObjectAnimator;
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.ComponentName;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.ServiceConnection;
|
|
|
+import android.content.pm.ActivityInfo;
|
|
|
+import android.content.res.Configuration;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.net.Uri;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.IBinder;
|
|
|
+import android.os.Looper;
|
|
|
+import android.provider.Settings;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.View;
|
|
|
+import android.view.WindowManager;
|
|
|
+import android.widget.FrameLayout;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.airbnb.lottie.LottieAnimationView;
|
|
|
+import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
+import com.alibaba.android.arouter.launcher.ARouter;
|
|
|
+import com.bumptech.glide.Glide;
|
|
|
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
|
+import com.cooleshow.base.utils.AppUtils;
|
|
|
+import com.cooleshow.base.utils.GsonUtils;
|
|
|
+import com.cooleshow.base.utils.LOG;
|
|
|
+import com.cooleshow.base.utils.PermissionUtils;
|
|
|
+import com.cooleshow.base.utils.ToastUtil;
|
|
|
+import com.cooleshow.base.utils.UiUtils;
|
|
|
+import com.cooleshow.base.widgets.DensityUtil;
|
|
|
+import com.cooleshow.base.widgets.DialogUtil;
|
|
|
+import com.cooleshow.base.widgets.InputBar;
|
|
|
+import com.cooleshow.base.widgets.dialog.CommonConfirmDialog;
|
|
|
+import com.cooleshow.base.widgets.dialog.InputBarDialog;
|
|
|
+import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
+import com.daya.tclive.R;
|
|
|
+import com.daya.tclive.adapter.TTMessageAdapter;
|
|
|
+import com.daya.tclive.bean.FriendInfoBean;
|
|
|
+import com.daya.tclive.bean.LiveRoomInfoBean;
|
|
|
+import com.daya.tclive.bean.LiveStatusSEMIMsg;
|
|
|
+import com.daya.tclive.bean.SendUserInfo;
|
|
|
+import com.daya.tclive.bean.TTMessage;
|
|
|
+import com.daya.tclive.bean.TTUserInfo;
|
|
|
+import com.daya.tclive.constants.ARouterConstace;
|
|
|
+import com.daya.tclive.constants.LiveRoomMsgConstants;
|
|
|
+import com.daya.tclive.constants.TTLiveConfig;
|
|
|
+import com.daya.tclive.contract.TTLiveRoomContract;
|
|
|
+import com.daya.tclive.databinding.AcTtLiveroomLayoutBinding;
|
|
|
+import com.daya.tclive.helper.LiveMemberHelper;
|
|
|
+import com.daya.tclive.helper.LiveMessageHelper;
|
|
|
+import com.daya.tclive.helper.LiveRoomAddLikeHelper;
|
|
|
+import com.daya.tclive.helper.LiveRoomAnimatorHelper;
|
|
|
+import com.daya.tclive.helper.TTLiveHelper;
|
|
|
+import com.daya.tclive.manager.TCIMSdkManager;
|
|
|
+import com.daya.tclive.manager.TRTCSdkManager;
|
|
|
+import com.daya.tclive.message.TCKickOutUserMessage;
|
|
|
+import com.daya.tclive.message.TCLiveForceKickMessage;
|
|
|
+import com.daya.tclive.message.TCSyncAddLikeMessage;
|
|
|
+import com.daya.tclive.message.TCUserEnterMessage;
|
|
|
+import com.daya.tclive.message.TCUserLogOutUnNormalMessage;
|
|
|
+import com.daya.tclive.message.TCUserSeatApplyMessage;
|
|
|
+import com.daya.tclive.message.TCUserSeatResponseMessage;
|
|
|
+import com.daya.tclive.message.TCUserSnappingUpMessage;
|
|
|
+import com.daya.tclive.presenter.TTLiveRoomPresenter;
|
|
|
+import com.daya.tclive.ui.floatPop.FloatWindowHelper;
|
|
|
+import com.daya.tclive.ui.floatPop.FloatingWindowService;
|
|
|
+import com.daya.tclive.widget.TTLiveRoomMicIconView;
|
|
|
+import com.daya.tclive.widget.dialog.LiveRoomCloseMicTipDialog;
|
|
|
+import com.daya.tclive.widget.dialog.LiveRoomClosePageOnMicTipDialog;
|
|
|
+import com.daya.tclive.widget.dialog.LiveRoomExitTipDialog2;
|
|
|
+import com.daya.tclive.widget.dialog.LiveRoomInviteSeatMicTipDialog;
|
|
|
+import com.daya.tclive.widget.dialog.LiveRoomMicManagerDialog;
|
|
|
+import com.daya.tclive.widget.dialog.LiveRoomShopCarDialog;
|
|
|
+import com.daya.tclive.widget.dialog.OpenOverlayPermissionTipDialog;
|
|
|
+import com.gyf.immersionbar.ImmersionBar;
|
|
|
+import com.tbruyelle.rxpermissions3.RxPermissions;
|
|
|
+import com.tencent.imsdk.v2.V2TIMManager;
|
|
|
+import com.tencent.imsdk.v2.V2TIMSDKListener;
|
|
|
+import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
|
|
+import com.tencent.imsdk.v2.V2TIMUserStatus;
|
|
|
+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.tencent.trtc.TRTCStatistics;
|
|
|
+
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import androidx.annotation.NonNull;
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
+import androidx.constraintlayout.widget.ConstraintSet;
|
|
|
+import androidx.constraintlayout.widget.Group;
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
+
|
|
|
+import static com.tencent.live2.V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Author by pq, Date on 2023/2/22.
|
|
|
+ */
|
|
|
+@Route(path = ARouterConstace.ACTIVITY_TT_LIVE_ROOM)
|
|
|
+public class TCStudentLiveRoomActivity extends BaseMVPActivity<AcTtLiveroomLayoutBinding,TTLiveRoomPresenter> implements TTLiveRoomContract.View, View.OnClickListener {
|
|
|
+ public static final String TAG = "TTLiveRoomActivity";
|
|
|
+
|
|
|
+ ConstraintLayout content_view;
|
|
|
+ TXCloudVideoView mVideoView;
|
|
|
+ FrameLayout flVideoContainer;
|
|
|
+ ConstraintLayout csVideoContainer;
|
|
|
+ Group mGroupViews;
|
|
|
+ FrameLayout mFlJoinBarrage;
|
|
|
+ ImageView mIvClose;
|
|
|
+ FrameLayout mFlSnapUpBarrage;
|
|
|
+ ImageView mIvSwitchVideoOrientation;
|
|
|
+ ImageView mIvSwitchVideoOrientationFull;
|
|
|
+ ConstraintLayout cs_header_info;
|
|
|
+ FrameLayout msgContainer;
|
|
|
+ TextView tv_input;
|
|
|
+ FrameLayout fl_input;
|
|
|
+ RecyclerView mRecyclerMsg;
|
|
|
+ ConstraintLayout mViewLiveStatus;
|
|
|
+ ConstraintLayout viewLiveCameraStatus;
|
|
|
+ ImageView mIvLiveStatusCameraCenterIcon;
|
|
|
+ TextView mTvLiveCameraStatusTipText;
|
|
|
+ ImageView mIvLiveStatusCenterIcon;
|
|
|
+ TextView mTvLiveStatusTipText;
|
|
|
+ TextView mTvJoinBarrage;
|
|
|
+ TextView mTvSnapUpBarrage;
|
|
|
+ TextView mTvAddLikeCount;
|
|
|
+ TextView mTvNumPeople;
|
|
|
+ ImageView iv_mic;
|
|
|
+ LottieAnimationView mViewShopCarAnim;
|
|
|
+ ImageView mIvShopCar;
|
|
|
+ ImageView mIvAvatar;
|
|
|
+ TextView mTvRoomCreateName;
|
|
|
+ ImageView mIvVoiceSwitch;
|
|
|
+ Group group_tip;
|
|
|
+ Group group_loading;
|
|
|
+ TextView tv_retry;
|
|
|
+ TextView tv_loading;
|
|
|
+ TTLiveRoomMicIconView mLlMicContainer;
|
|
|
+ TXCloudVideoView subVideoView;
|
|
|
+ private ServiceConnection serviceConnection;
|
|
|
+ public static final int SEND_SHOW_FLOAT_WINDOW_TIME = 1000;//退到后台以后检查是否显示悬浮窗等待时长
|
|
|
+ public static final int SEND_APP_BACKGROUND_MSG = 1001;//退到后台消息
|
|
|
+ public static final int SEND_JUMP_OTHER_PAGE_MSG = 1002;//页面切换消息(购物车详情页等等)
|
|
|
+ public static final int OPEN_SHOP_CAR_DIALOG = 1003;//打开购物车
|
|
|
+
|
|
|
+
|
|
|
+ public static final int LIVE_STATUS_IS_REST = 1;//休息一下,马上回来
|
|
|
+ public static final int LIVE_STATUS_IS_CLOSE_VIDEO = 2;//主持人关闭画面
|
|
|
+ public static final int LIVE_STATUS_IS_OFFLINE = 3;//直播已结束
|
|
|
+ public static final int LIVE_STATUS_LOADING = 4;//直播加载中
|
|
|
+ public static final int LIVE_STATUS_ERROR = 5;//直播加载中出错
|
|
|
+ private static final String ROOMID_KEY = "roomid_key";
|
|
|
+ private static final String SUBJECT_ID_KEY = "subject_id_key";
|
|
|
+ private String mRoomId = "";
|
|
|
+ private String mUserId = "";
|
|
|
+ private ObjectAnimator hideHeaderInfoAnim;
|
|
|
+ private ObjectAnimator showHeaderInfoAnim;
|
|
|
+ private boolean isEnableChat = false;//默认不禁止
|
|
|
+ private boolean isEnableMic = false;//默认不禁止
|
|
|
+ private boolean isEnableAll = false;//默认不禁止 黑名单状态
|
|
|
+ private boolean isPcClientLive = true;//默认为PC端直播
|
|
|
+ private boolean isMuteAllMic = false;//默认为不禁止麦克风
|
|
|
+ private boolean isNeedRefresh = false;//是否需要重新刷新房间信息
|
|
|
+ private boolean liveIsFinish = false;//直播间是否已结束
|
|
|
+ private boolean liveIsPause = false;//直播间是否已暂停
|
|
|
+ private long currentAddLikeCount = 0;//当前点赞数量
|
|
|
+ private int currentSeatStatus = LiveRoomMsgConstants.MIC_STATUS_NORMAL;//1未连麦,2连麦中,3连麦成功
|
|
|
+ private LiveRoomInfoBean roomInfo;
|
|
|
+ private InputBarDialog mInputBarDialog;
|
|
|
+ private LiveRoomMicManagerDialog mMicManagerDialog;
|
|
|
+ private LiveRoomInviteSeatMicTipDialog mInviteSeatMicTipDialog;
|
|
|
+ private LiveRoomShopCarDialog mShopCarDialog;
|
|
|
+ private V2TXLivePlayer mMLivePlayer;
|
|
|
+ private boolean isMuteAll = false;//是否静音
|
|
|
+ private boolean isConnectImFailed = false;//IM状态是否异常
|
|
|
+ private boolean isOnResume = true;
|
|
|
+ private Handler mHandler = new Handler(Looper.myLooper()) {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(@NonNull android.os.Message msg) {
|
|
|
+ if (msg.what == SEND_APP_BACKGROUND_MSG) {
|
|
|
+ //APP切换后台 isOnResume要等于false
|
|
|
+ //开启悬浮窗
|
|
|
+ if (!isOnResume && AppUtils.isApplicationInBackground(TCStudentLiveRoomActivity.this)) {
|
|
|
+ startFloatWindowService();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (msg.what == SEND_JUMP_OTHER_PAGE_MSG) {
|
|
|
+ //跳转其他页面时候
|
|
|
+ //开启悬浮窗
|
|
|
+ if (isOnResume) {
|
|
|
+ //如果页面onResume了,就不开启service
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ startFloatWindowService();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (msg.what == OPEN_SHOP_CAR_DIALOG) {
|
|
|
+ showShopCarDialog();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ private V2TIMSDKListener mTIMSDKListener = new V2TIMSDKListener() {
|
|
|
+ @Override
|
|
|
+ public void onConnecting() {
|
|
|
+ super.onConnecting();
|
|
|
+ Log.i(TAG, "onConnecting");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onConnectSuccess() {
|
|
|
+ super.onConnectSuccess();
|
|
|
+ Log.i(TAG, "onConnectSuccess");
|
|
|
+ if (isConnectImFailed) {
|
|
|
+ if (isOnMic()) {
|
|
|
+ handleCloseMicEvent();
|
|
|
+ }
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_JOIN_ROOM);
|
|
|
+ presenter.notifyJoinRoomAction(mRoomId, mUserId);
|
|
|
+ presenter.getAllGroupAttributes(mRoomId);
|
|
|
+ presenter.getAllGroupCounter(mRoomId);
|
|
|
+ play();
|
|
|
+ }
|
|
|
+ isConnectImFailed = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onConnectFailed(int code, String error) {
|
|
|
+ super.onConnectFailed(code, error);
|
|
|
+ Log.i(TAG, "onConnectFailed");
|
|
|
+ isConnectImFailed = true;
|
|
|
+ showLiveStatusView(LIVE_STATUS_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onKickedOffline() {
|
|
|
+ super.onKickedOffline();
|
|
|
+ Log.i(TAG, "onKickedOffline");
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserSigExpired() {
|
|
|
+ super.onUserSigExpired();
|
|
|
+ Log.i(TAG, "onUserSigExpired");
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSelfInfoUpdated(V2TIMUserFullInfo info) {
|
|
|
+ super.onSelfInfoUpdated(info);
|
|
|
+ Log.i(TAG, "onSelfInfoUpdated");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserStatusChanged(List<V2TIMUserStatus> userStatusList) {
|
|
|
+ super.onUserStatusChanged(userStatusList);
|
|
|
+
|
|
|
+ String myselfUserID = V2TIMManager.getInstance().getLoginUser();
|
|
|
+ for (V2TIMUserStatus item : userStatusList) {
|
|
|
+ Log.i(TAG, "onUserStatusChanged");
|
|
|
+ if (item.getUserID().equals(myselfUserID)) {
|
|
|
+ // 自己的状态发生变更
|
|
|
+ int statusType = item.getStatusType();
|
|
|
+ Log.i(TAG, "onUserStatusChanged statusType:" + statusType);
|
|
|
+ if (statusType == V2TIMUserStatus.V2TIM_USER_STATUS_OFFLINE) {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 其他人的状态发生变更
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ private TTMessageAdapter mMessageAdapter;
|
|
|
+ private LinearLayoutManager mLinearLayoutManager;
|
|
|
+ private boolean isAutoScrollToLast = true;
|
|
|
+ private boolean anchorIsOnline = false;//主播是否在线
|
|
|
+ private LiveRoomCloseMicTipDialog mRoomCloseMicTipDialog;
|
|
|
+ private LiveRoomClosePageOnMicTipDialog mLiveRoomClosePageOnMicTipDialog;
|
|
|
+ private String subjectId;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected AcTtLiveroomLayoutBinding getLayoutView() {
|
|
|
+ return AcTtLiveroomLayoutBinding.inflate(getLayoutInflater());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initView() {
|
|
|
+ setStatusBarColor();
|
|
|
+ content_view = viewBinding.contentView;
|
|
|
+ mVideoView= viewBinding.videoView;
|
|
|
+ flVideoContainer= viewBinding.flVideoContainer;
|
|
|
+ csVideoContainer= viewBinding.csVideoContainer;
|
|
|
+ mGroupViews= viewBinding.groupViews;
|
|
|
+ mFlJoinBarrage= viewBinding.flJoinBarrage;
|
|
|
+ mIvClose = viewBinding.ivClose;
|
|
|
+ mFlSnapUpBarrage = viewBinding.flSnapUpBarrage;
|
|
|
+ mIvSwitchVideoOrientation = viewBinding.ivSwitchVideoOrientation;
|
|
|
+ mIvSwitchVideoOrientationFull = viewBinding.ivSwitchVideoOrientationFull;
|
|
|
+ cs_header_info = viewBinding.csHeaderInfo;
|
|
|
+ msgContainer = viewBinding.flRecyclerContainer;
|
|
|
+ tv_input = viewBinding.tvInput;
|
|
|
+ fl_input = viewBinding.flInput;
|
|
|
+ mRecyclerMsg = viewBinding.recyclerMsg;
|
|
|
+ mViewLiveStatus = viewBinding.viewLiveStatus.csRoot;
|
|
|
+ viewLiveCameraStatus = viewBinding.viewLiveStatus.csRoot;
|
|
|
+ mIvLiveStatusCameraCenterIcon = viewBinding.viewLiveCameraStatus.ivCameraCenterIcon;
|
|
|
+ mTvLiveCameraStatusTipText = viewBinding.viewLiveCameraStatus.tvLiveCameraStatusTipText;
|
|
|
+ mIvLiveStatusCenterIcon = viewBinding.viewLiveStatus.ivCenterIcon;
|
|
|
+ mTvLiveStatusTipText = viewBinding.viewLiveStatus.tvLiveStatusTipText;
|
|
|
+ mTvJoinBarrage = viewBinding.tvJoinBarrage;
|
|
|
+ mTvSnapUpBarrage = viewBinding.tvSnapUpBarrage;
|
|
|
+ mTvAddLikeCount = viewBinding.tvAddLikeCount;
|
|
|
+ mTvNumPeople = viewBinding.tvNumPeople;
|
|
|
+ iv_mic = viewBinding.ivMic;
|
|
|
+ mViewShopCarAnim = viewBinding.viewShopCarAnim;
|
|
|
+ mIvShopCar = viewBinding.ivShopCar;
|
|
|
+ mIvAvatar = viewBinding.ivAvatar;
|
|
|
+ mTvRoomCreateName = viewBinding.tvRoomAuthorName;
|
|
|
+ mIvVoiceSwitch = viewBinding.ivVoiceSwitch;
|
|
|
+ group_tip = viewBinding.viewLiveStatus.groupTip;
|
|
|
+ group_loading = viewBinding.viewLiveStatus.groupLoading;
|
|
|
+ tv_retry = viewBinding.viewLiveStatus.tvRetry;
|
|
|
+ tv_loading = viewBinding.viewLiveStatus.tvLoading;
|
|
|
+ mLlMicContainer = viewBinding.llMicContainer;
|
|
|
+ subVideoView = viewBinding.subVideoView;
|
|
|
+
|
|
|
+ mRoomId = getIntent().getStringExtra(ROOMID_KEY);
|
|
|
+ if (getIntent().hasExtra(SUBJECT_ID_KEY)) {
|
|
|
+ subjectId = getIntent().getStringExtra(SUBJECT_ID_KEY);
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(mRoomId)) {
|
|
|
+ ToastUtil.getInstance().show(this, "房间id不可为空");
|
|
|
+ finish();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mMessageAdapter = new TTMessageAdapter(this);
|
|
|
+ mLinearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
|
|
|
+ mRecyclerMsg.setLayoutManager(mLinearLayoutManager);
|
|
|
+ mRecyclerMsg.setAdapter(mMessageAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setStatusBarColor() {
|
|
|
+ ImmersionBar.with(this)
|
|
|
+ .keyboardEnable(false)//为了防止软键盘顶起底部布局
|
|
|
+ .transparentStatusBar()
|
|
|
+ .statusBarDarkFont(false, 0.2f) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持状态栏字体变色,会使当前状态栏加上透明度,否则不执行透明度
|
|
|
+ .autoDarkModeEnable(false)
|
|
|
+ .flymeOSStatusBarFontColor(R.color.white) //修改flyme OS状态栏字体颜色
|
|
|
+ .init(); //必须调用方可沉浸
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initData() {
|
|
|
+ super.initData();
|
|
|
+ initIMSdk();
|
|
|
+ mUserId = UserHelper.getImUserId();
|
|
|
+ //创建 player 对象
|
|
|
+ mMLivePlayer = new V2TXLivePlayerImpl(this);
|
|
|
+ mMLivePlayer.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFill);
|
|
|
+ // 设置画面渲染方向
|
|
|
+ mMLivePlayer.setRenderRotation(V2TXLiveRotation0);
|
|
|
+ //关键 player 对象与界面 view
|
|
|
+ mMLivePlayer.setRenderView(mVideoView);
|
|
|
+ mMLivePlayer.enableReceiveSeiMessage(true, TTLiveConfig.DEFAULT_PAYLOAD_TYPE);
|
|
|
+ presenter.init(this,mRoomId);
|
|
|
+ initListener();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initIMSdk() {
|
|
|
+ TCIMSdkManager.getInstance().init(getApplication());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initListener() {
|
|
|
+ initViewClickListener();
|
|
|
+ TCIMSdkManager.getInstance().addEventListener(mTIMSDKListener);
|
|
|
+
|
|
|
+ mRecyclerMsg.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
|
+ @Override
|
|
|
+ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
|
|
+ super.onScrollStateChanged(recyclerView, newState);
|
|
|
+ if (mLinearLayoutManager == null || mMessageAdapter == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int lastCompletelyVisibleItemPosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition();
|
|
|
+ if (lastCompletelyVisibleItemPosition == mMessageAdapter.getMessageSize() - 1) {
|
|
|
+ isAutoScrollToLast = true;
|
|
|
+ } else {
|
|
|
+ isAutoScrollToLast = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mMLivePlayer.setObserver(new V2TXLivePlayerObserver() {
|
|
|
+ @Override
|
|
|
+ public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
|
|
+ super.onError(player, code, msg, extraInfo);
|
|
|
+ Log.i("pq", "play error:code=" + code + "---msg:" + msg + "---Bundle:" + extraInfo.toString());
|
|
|
+ if (anchorIsOnline) {
|
|
|
+ showLiveStatusView(LIVE_STATUS_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
|
|
+ super.onWarning(player, code, msg, extraInfo);
|
|
|
+ Log.i("pq", "play onWarning:code=" + code + "---msg:" + msg + "---Bundle:" + extraInfo.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onConnected(V2TXLivePlayer player, Bundle extraInfo) {
|
|
|
+ super.onConnected(player, extraInfo);
|
|
|
+ Log.i("pq", "play onConnected:" + extraInfo.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveDef.V2TXLiveVideoFrame videoFrame) {
|
|
|
+ super.onRenderVideoFrame(player, videoFrame);
|
|
|
+ Log.i("pq", "play onRenderVideoFrame:" + videoFrame);
|
|
|
+ hideLiveStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onVideoLoading(V2TXLivePlayer player, Bundle extraInfo) {
|
|
|
+ super.onVideoLoading(player, extraInfo);
|
|
|
+ Log.i("pq", "play onVideoLoading:" + extraInfo.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onVideoPlaying(V2TXLivePlayer player, boolean firstPlay, Bundle extraInfo) {
|
|
|
+ super.onVideoPlaying(player, firstPlay, extraInfo);
|
|
|
+ Log.i("pq", "play onVideoPlaying:" + extraInfo.toString() + "---isFirstPlay:" + firstPlay);
|
|
|
+ hideLiveStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) {
|
|
|
+ super.onReceiveSeiMessage(player, payloadType, data);
|
|
|
+ Log.i("pq", "play onReceiveSeiMessage:length" + data.length + "---" + payloadType + "---data:" + new String(data));
|
|
|
+ if (data != null && data.length > 0) {
|
|
|
+ parseSeiMessage(new String(data));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStatisticsUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayerStatistics statistics) {
|
|
|
+ super.onStatisticsUpdate(player, statistics);
|
|
|
+// Log.i("pq", "play videoBitrate:" + statistics.videoBitrate);
|
|
|
+// Log.i("pq", "play audioBitrate:" + statistics.audioBitrate);
|
|
|
+// Log.i("pq", "play videoPacketLoss:" + statistics.videoPacketLoss);
|
|
|
+// Log.i("pq", "play audioPacketLoss:" + statistics.audioPacketLoss);
|
|
|
+// Log.i("pq", "play videoBlockRate:" + statistics.videoBlockRate);
|
|
|
+// Log.i("pq", "play aul dioBlockRate:" + statistics.audioBlockRate);
|
|
|
+// Log.i("pq", "play videoTotalBlockTime:" + statistics.videoTotalBlockTime);
|
|
|
+// Log.i("pq", "play audioTotalBlockTime:" + statistics.audioTotalBlockTime);
|
|
|
+// Log.i("pq", "play rtt:" + statistics.rtt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mLlMicContainer.setOnEventListener(new TTLiveRoomMicIconView.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void getUserInfoByUserId(String userId) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.getUserInfoByUserId(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onMicStatusUpdate(String userId, String currentMicStatus) {
|
|
|
+ boolean isOpen = !TextUtils.equals(currentMicStatus, TTLiveConfig.LIVE_ROOM_MIC_STATUS_ON_VALUE);
|
|
|
+ changeMicStatus(userId, isOpen);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void changeMicStatus(String userId, boolean isOpenCloseMode) {
|
|
|
+ mLlMicContainer.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (isOpenCloseMode) {
|
|
|
+ //开启闭麦模式
|
|
|
+ mLlMicContainer.updateTargetUserMicStatus(userId, TTLiveConfig.LIVE_ROOM_MIC_STATUS_ON_VALUE);
|
|
|
+ presenter.setMicrophoneDisable(true);
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_MIC_STATUS_CHANGE, mUserId, true);
|
|
|
+ } else {
|
|
|
+ //关闭闭麦模式
|
|
|
+ mLlMicContainer.updateTargetUserMicStatus(userId, TTLiveConfig.LIVE_ROOM_MIC_STATUS_OFF_VALUE);
|
|
|
+ presenter.setMicrophoneDisable(false);
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_MIC_STATUS_CHANGE, mUserId, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void parseSeiMessage(String s) {
|
|
|
+ try {
|
|
|
+ Log.i("pq", "parseSeiMessage:" + s);
|
|
|
+ LiveStatusSEMIMsg semiMsg = GsonUtils.fromJson(s, LiveStatusSEMIMsg.class);
|
|
|
+ List<LiveStatusSEMIMsg.UserStatusBean> seatUser = semiMsg.getSeatUser();
|
|
|
+ mLlMicContainer.refreshAll(seatUser);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void notifyMicContainerDel(String userId) {
|
|
|
+ mLlMicContainer.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mLlMicContainer.deleteMicUser(userId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void notifyMicContainerAdd(String userId) {
|
|
|
+ Log.i("pq", "notifyMicContainerAdd:" + userId);
|
|
|
+ List<String> seatUser = new ArrayList<>();
|
|
|
+ seatUser.add(userId);
|
|
|
+ mLlMicContainer.addOnMicUser(seatUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void hideLiveStatus() {
|
|
|
+ if (mViewLiveStatus != null) {
|
|
|
+ mViewLiveStatus.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void hideLiveCameraStatus() {
|
|
|
+ if (viewLiveCameraStatus != null) {
|
|
|
+ viewLiveCameraStatus.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initViewClickListener(){
|
|
|
+ viewBinding.ivClose.setOnClickListener(this);
|
|
|
+ viewBinding.ivSwitchVideoOrientation.setOnClickListener(this);
|
|
|
+ viewBinding.flInput.setOnClickListener(this);
|
|
|
+ viewBinding.ivMic.setOnClickListener(this);
|
|
|
+ viewBinding.iconAddLike.setOnClickListener(this);
|
|
|
+ viewBinding.ivSwitchVideoOrientationFull.setOnClickListener(this);
|
|
|
+ viewBinding.viewLiveStatus.csRoot.setOnClickListener(this);
|
|
|
+ viewBinding.viewShopCarAnim.setOnClickListener(this);
|
|
|
+ viewBinding.flVideoContainer.setOnClickListener(this);
|
|
|
+ viewBinding.ivVoiceSwitch.setOnClickListener(this);
|
|
|
+ viewBinding.viewLiveStatus.tvRetry.setOnClickListener(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ int id = view.getId();
|
|
|
+ if (id == viewBinding.viewLiveStatus.csRoot.getId()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == R.id.iv_close) {
|
|
|
+ if (currentSeatStatus != LiveRoomMsgConstants.MIC_STATUS_NORMAL) {
|
|
|
+ showPageCloseOnMicTipDialog();
|
|
|
+ } else {
|
|
|
+ close();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == R.id.iv_switch_video_orientation) {
|
|
|
+ //切换横竖屏
|
|
|
+ if (UiUtils.isFastClick()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mShopCarDialog != null && mShopCarDialog.isShowing()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ changeOrientation();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == R.id.iv_switch_video_orientation_full) {
|
|
|
+ //横屏切换竖屏
|
|
|
+ changeOrientation();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == R.id.fl_input) {
|
|
|
+ //底部输入框
|
|
|
+ showInputDialog();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == R.id.iv_mic) {
|
|
|
+ //连麦
|
|
|
+ toCheckMicPermission();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == R.id.icon_add_like) {
|
|
|
+ if (checkAddLikeMode()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //点赞
|
|
|
+ LiveRoomAddLikeHelper.getInstance().handleClick(new LiveRoomAddLikeHelper.OnAddLikeResultCallBack() {
|
|
|
+ @Override
|
|
|
+ public void onResult(int count) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.updateGroupAddLike(mRoomId, count);
|
|
|
+// presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_ADD_LIKE_COUNT, count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ LiveRoomAnimatorHelper.getInstance().startAddLikeAnimation(TCStudentLiveRoomActivity.this, content_view);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == R.id.view_shop_car_anim) {
|
|
|
+ if (liveIsFinish) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "直播已结束");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //购物车
|
|
|
+ if (isFullScreen()) {
|
|
|
+ changeOrientation();
|
|
|
+ android.os.Message message = android.os.Message.obtain();
|
|
|
+ message.what = OPEN_SHOP_CAR_DIALOG;
|
|
|
+ mHandler.sendMessageDelayed(message, 500);
|
|
|
+ } else {
|
|
|
+ showShopCarDialog();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == R.id.fl_video_container) {
|
|
|
+ //点击隐藏头部信息
|
|
|
+ if (isFullScreen()) {
|
|
|
+ //全屏模式下
|
|
|
+ handleHeaderAnim();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == R.id.iv_voice_switch) {
|
|
|
+// //静音
|
|
|
+ if (isMuteAll) {
|
|
|
+ this.isMuteAll = false;
|
|
|
+ mIvVoiceSwitch.setImageResource(R.drawable.icon_live_voice_on);
|
|
|
+ muteAll(false);
|
|
|
+ } else {
|
|
|
+ mIvVoiceSwitch.setImageResource(R.drawable.icon_live_voice_off);
|
|
|
+ this.isMuteAll = true;
|
|
|
+ muteAll(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == R.id.tv_retry) {
|
|
|
+ play();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("CheckResult")
|
|
|
+ private void toCheckMicPermission() {
|
|
|
+ new RxPermissions(this)
|
|
|
+ .request(Manifest.permission.RECORD_AUDIO,
|
|
|
+ Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
+ .subscribe(permission -> {
|
|
|
+ if (permission) {
|
|
|
+ handleMicClick();
|
|
|
+ } else {
|
|
|
+ DialogUtil.showInCenter(getSupportFragmentManager(), com.cooleshow.base.R.layout.common_popu, (holder, dialog) -> {
|
|
|
+ TextView tvTitle = holder.getView(com.cooleshow.base.R.id.tv_title);
|
|
|
+ TextView tvContent = holder.getView(com.cooleshow.base.R.id.tv_content);
|
|
|
+ TextView btncancel = holder.getView(com.cooleshow.base.R.id.btn_cancel);
|
|
|
+ TextView btnCommit = holder.getView(com.cooleshow.base.R.id.btn_commit);
|
|
|
+ tvTitle.setText("提示");
|
|
|
+ tvContent.setText("连麦需要麦克风、储存权限,去设置?");
|
|
|
+ btncancel.setOnClickListener(view1 -> {
|
|
|
+ dialog.dismiss();
|
|
|
+ });
|
|
|
+ btnCommit.setOnClickListener(view1 -> {
|
|
|
+ PermissionUtils.toSelfSetting(getApplicationContext());
|
|
|
+ dialog.dismiss();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleMicClick() {
|
|
|
+ if (!isOnMic()) {
|
|
|
+ //非连麦中才判断模式
|
|
|
+ if (checkMicMode()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isConnectImFailed) {
|
|
|
+ //连接状态异常,暂停连麦
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showMicManagerDialog();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 是否静音全部
|
|
|
+ *
|
|
|
+ * @param isMute
|
|
|
+ */
|
|
|
+ private void muteAll(boolean isMute) {
|
|
|
+ mMLivePlayer.setPlayoutVolume(isMute ? 0 : 100);
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.muteTRTC(isMute);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showPageCloseOnMicTipDialog() {
|
|
|
+ if (mLiveRoomClosePageOnMicTipDialog == null) {
|
|
|
+ mLiveRoomClosePageOnMicTipDialog = new LiveRoomClosePageOnMicTipDialog(this);
|
|
|
+ mLiveRoomClosePageOnMicTipDialog.setConfirmClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!mLiveRoomClosePageOnMicTipDialog.isShowing()) {
|
|
|
+ mLiveRoomClosePageOnMicTipDialog.show();
|
|
|
+ }
|
|
|
+ mLiveRoomClosePageOnMicTipDialog.setTitle("提示");
|
|
|
+ mLiveRoomClosePageOnMicTipDialog.setContent("连麦中,是否退出房间?");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void close() {
|
|
|
+ //断开连接,结束页面
|
|
|
+ onBackPressed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onBackPressed() {
|
|
|
+ if (liveIsFinish) {
|
|
|
+ super.onBackPressed();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isFullScreen()) {
|
|
|
+ changeOrientation();
|
|
|
+ } else {
|
|
|
+ boolean permissionOverlay = FloatWindowHelper.requestOverlayPermission(this);
|
|
|
+ if (!permissionOverlay) {
|
|
|
+ showOpenOverlayPermissionTipDialog();
|
|
|
+ } else {
|
|
|
+ showExitLiveTipDialog();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showOpenOverlayPermissionTipDialog() {
|
|
|
+ OpenOverlayPermissionTipDialog overlayPermissionTipDialog = new OpenOverlayPermissionTipDialog(this);
|
|
|
+ overlayPermissionTipDialog.setConfirmClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ overlayPermissionTipDialog.dismiss();
|
|
|
+ Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
|
|
|
+ startActivityForResult(intent, FloatWindowHelper.REQUEST_OVERLAY_CODE);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ overlayPermissionTipDialog.show();
|
|
|
+ overlayPermissionTipDialog.setCancelClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ overlayPermissionTipDialog.dismiss();
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退出直播间提示弹窗
|
|
|
+ */
|
|
|
+ private void showExitLiveTipDialog() {
|
|
|
+ LiveRoomExitTipDialog2 liveRoomExitTipDialog2 = new LiveRoomExitTipDialog2(this);
|
|
|
+ liveRoomExitTipDialog2.setConfirmClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ liveRoomExitTipDialog2.show();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showInputDialog() {
|
|
|
+ if (roomInfo == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (checkChatMode()) return;
|
|
|
+ if (mInputBarDialog == null) {
|
|
|
+ mInputBarDialog = new InputBarDialog(TCStudentLiveRoomActivity.this, new InputBar.InputBarListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onClickSend(String message) {
|
|
|
+ //发送消息
|
|
|
+ if (checkChatMode()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(message)) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "消息不能为空");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (message.length() > TTLiveConfig.LIVE_MAX_INPUT_TEXT_LENGTH) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "聊天消息需在40个字以内哦");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (LiveMessageHelper.isQuickAction()) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "您说话太快啦");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ sendTextMessage(message);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onClickEmoji() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mInputBarDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
|
|
+ @Override
|
|
|
+ public void onShow(DialogInterface dialog) {
|
|
|
+ if (mInputBarDialog != null) {
|
|
|
+ mInputBarDialog.showInput();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!mInputBarDialog.isShowing()) {
|
|
|
+ mInputBarDialog.show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendTextMessage(String message) {
|
|
|
+ presenter.sendTextMessage(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查点赞按钮是否可用
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean checkAddLikeMode() {
|
|
|
+ if (liveIsFinish) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "直播已结束");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+// if (isEnableAll) {
|
|
|
+// ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "您已被管理员禁言");
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+
|
|
|
+ if (isConnectImFailed) {
|
|
|
+ //连接状态异常,暂停点赞
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "网络连接状态异常");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void changeOrientation() {
|
|
|
+ int currentOrientation = getCurrentOrientation();
|
|
|
+ boolean isNeedFullScreen = currentOrientation != Configuration.ORIENTATION_LANDSCAPE;
|
|
|
+ if (isNeedFullScreen) {
|
|
|
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
|
+ } else {
|
|
|
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void startFloatWindowService() {
|
|
|
+ boolean hasPermission = FloatWindowHelper.requestOverlayPermission(this);
|
|
|
+ if (hasPermission) {
|
|
|
+ Intent intent = new Intent(this, FloatingWindowService.class);
|
|
|
+ initServiceConnection();
|
|
|
+ intent.putExtra("isPc", isPcClientLive);
|
|
|
+ bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initServiceConnection() {
|
|
|
+ if (serviceConnection == null) {
|
|
|
+ serviceConnection = new ServiceConnection() {
|
|
|
+ @Override
|
|
|
+ public void onServiceConnected(ComponentName name, IBinder service) {
|
|
|
+ if (service instanceof FloatingWindowService.MyBinder) {
|
|
|
+ FloatingWindowService.MyBinder mBinder = (FloatingWindowService.MyBinder) service;
|
|
|
+ ArrayList<View> list = new ArrayList();
|
|
|
+ list.add(getVideoView());
|
|
|
+ mBinder.addTTVideoView(list);
|
|
|
+ mBinder.setOnEventListener(new FloatingWindowService.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void onServiceDestroy() {
|
|
|
+ if (flVideoContainer != null) {
|
|
|
+ flVideoContainer.addView(getVideoView());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUnbindService() {
|
|
|
+ muteAll(true);
|
|
|
+ unbindService();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onServiceDisconnected(ComponentName name) {
|
|
|
+ if (flVideoContainer != null) {
|
|
|
+ flVideoContainer.addView(getVideoView());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 销毁悬浮窗service
|
|
|
+ */
|
|
|
+ private void unbindService() {
|
|
|
+ if (serviceConnection != null) {
|
|
|
+ try {
|
|
|
+ boolean isExist = AppUtils.isServiceWork(this, FloatingWindowService.CLASS_PATH);
|
|
|
+ if (isExist) {
|
|
|
+ unbindService(serviceConnection);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public View getVideoView() {
|
|
|
+ return csVideoContainer;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private boolean isFullScreen() {
|
|
|
+ return getCurrentOrientation() == Configuration.ORIENTATION_LANDSCAPE;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private int getCurrentOrientation() {
|
|
|
+ return getResources().getConfiguration().orientation;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
|
|
+ super.onConfigurationChanged(newConfig);
|
|
|
+ //改变videoView容器布局尺寸
|
|
|
+ resetVideoContainer(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void resetVideoContainer(boolean isFullScreen) {
|
|
|
+ if (isFullScreen) {
|
|
|
+ if (isPcClientLive) {
|
|
|
+ //隐藏消息列表
|
|
|
+ mGroupViews.setVisibility(View.GONE);
|
|
|
+ mIvClose.setVisibility(View.GONE);
|
|
|
+ //隐藏弹幕消息
|
|
|
+ mFlJoinBarrage.clearAnimation();
|
|
|
+ mFlJoinBarrage.setVisibility(View.GONE);
|
|
|
+ mFlSnapUpBarrage.clearAnimation();
|
|
|
+ mFlSnapUpBarrage.setVisibility(View.GONE);
|
|
|
+ //隐藏竖屏全屏按钮
|
|
|
+ mIvSwitchVideoOrientation.setVisibility(View.GONE);
|
|
|
+ mIvSwitchVideoOrientationFull.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ //不是PC端直播
|
|
|
+ mIvSwitchVideoOrientation.setVisibility(View.GONE);
|
|
|
+ mIvSwitchVideoOrientationFull.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ ConstraintSet set = new ConstraintSet();
|
|
|
+ set.clone(content_view);
|
|
|
+ set.clear(flVideoContainer.getId());
|
|
|
+ if (!isPcClientLive) {
|
|
|
+ //如果是非PC端直播,还需要设置下消息列表控件位置
|
|
|
+ set.clear(msgContainer.getId());
|
|
|
+ set.connect(msgContainer.getId(), ConstraintSet.TOP, R.id.view_center, ConstraintSet.BOTTOM, DensityUtil.dp2px(TCStudentLiveRoomActivity.this, 50));
|
|
|
+ set.connect(msgContainer.getId(), ConstraintSet.LEFT, content_view.getId(), ConstraintSet.LEFT, 0);
|
|
|
+ set.connect(msgContainer.getId(), ConstraintSet.RIGHT, content_view.getId(), ConstraintSet.RIGHT, 0);
|
|
|
+ set.connect(msgContainer.getId(), ConstraintSet.BOTTOM, fl_input.getId(), ConstraintSet.TOP, DensityUtil.dp2px(TCStudentLiveRoomActivity.this, 10));
|
|
|
+ }
|
|
|
+ set.connect(flVideoContainer.getId(), ConstraintSet.TOP, content_view.getId(), ConstraintSet.TOP, 0);
|
|
|
+ set.connect(flVideoContainer.getId(), ConstraintSet.LEFT, content_view.getId(), ConstraintSet.LEFT, 0);
|
|
|
+ set.connect(flVideoContainer.getId(), ConstraintSet.RIGHT, content_view.getId(), ConstraintSet.RIGHT, 0);
|
|
|
+ set.connect(flVideoContainer.getId(), ConstraintSet.BOTTOM, content_view.getId(), ConstraintSet.BOTTOM, 0);
|
|
|
+ set.applyTo(content_view);
|
|
|
+ } else {
|
|
|
+ //pc端直播,控制居中显示,以及videoview容器的宽高
|
|
|
+ if (cs_header_info.getTranslationY() != 0) {
|
|
|
+ //还原显示头部信息
|
|
|
+ handleHeaderAnim();
|
|
|
+ }
|
|
|
+ if (isPcClientLive) {
|
|
|
+ mGroupViews.setVisibility(View.VISIBLE);
|
|
|
+ mIvClose.setVisibility(View.VISIBLE);
|
|
|
+ mIvSwitchVideoOrientation.setVisibility(View.VISIBLE);
|
|
|
+ mIvSwitchVideoOrientationFull.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ ConstraintSet set = new ConstraintSet();
|
|
|
+ set.clone(content_view);
|
|
|
+ set.clear(flVideoContainer.getId());
|
|
|
+ set.connect(flVideoContainer.getId(), ConstraintSet.TOP, cs_header_info.getId(), ConstraintSet.BOTTOM, DensityUtil.dp2px(TCStudentLiveRoomActivity.this, 121));
|
|
|
+ set.connect(flVideoContainer.getId(), ConstraintSet.LEFT, content_view.getId(), ConstraintSet.LEFT, 0);
|
|
|
+ set.connect(flVideoContainer.getId(), ConstraintSet.RIGHT, content_view.getId(), ConstraintSet.RIGHT, 0);
|
|
|
+ int maxHeightAtRatio16_9 = UiUtils.getMaxHeightAtRatio16_9(TCStudentLiveRoomActivity.this);
|
|
|
+ set.constrainHeight(flVideoContainer.getId(), maxHeightAtRatio16_9);
|
|
|
+ set.applyTo(content_view);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleHeaderAnim() {
|
|
|
+ float animOffset = cs_header_info.getTranslationY();
|
|
|
+ if (animOffset == 0) {
|
|
|
+ //隐藏头部信息
|
|
|
+ int bottom = cs_header_info.getBottom();
|
|
|
+ if (hideHeaderInfoAnim == null) {
|
|
|
+ hideHeaderInfoAnim = ObjectAnimator.ofFloat(cs_header_info, "translationY", 0, -bottom);
|
|
|
+ hideHeaderInfoAnim.setDuration(500);
|
|
|
+ }
|
|
|
+ hideHeaderInfoAnim.start();
|
|
|
+ } else {
|
|
|
+ //显示头部信息
|
|
|
+ if (showHeaderInfoAnim == null) {
|
|
|
+ showHeaderInfoAnim = ObjectAnimator.ofFloat(cs_header_info, "translationY", animOffset, 0);
|
|
|
+ showHeaderInfoAnim.setDuration(500);
|
|
|
+ }
|
|
|
+ showHeaderInfoAnim.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 控制聊天模式
|
|
|
+ *
|
|
|
+ * @param isEnableChat
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void switchChatMode(boolean isEnableChat) {
|
|
|
+ //控制聊天模式
|
|
|
+ Log.i("pq", "聊天禁止:" + isEnableChat);
|
|
|
+ this.isEnableChat = isEnableChat;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changeMicControlMode(boolean isEnableMic) {
|
|
|
+ //禁止连麦模式
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Log.i("pq", "receive mic mode control msg 禁麦模式:" + isEnableMic);
|
|
|
+ this.isEnableMic = isEnableMic;
|
|
|
+ if (isEnableMic && isOnApplyMic()) {
|
|
|
+ handleCloseMicEvent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void liveRoomOffline() {
|
|
|
+ //关闭直播间
|
|
|
+ ToastUtil.getInstance().show(this, "直播已结束");
|
|
|
+ this.liveIsFinish = true;
|
|
|
+ //取消连麦
|
|
|
+ if (mMicManagerDialog != null) {
|
|
|
+ mMicManagerDialog.dismiss();
|
|
|
+ }
|
|
|
+ presenter.exitRoom();
|
|
|
+ showLiveStatusView(LIVE_STATUS_IS_OFFLINE);
|
|
|
+ hideDialog();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void receiveJoinMessage(TCUserEnterMessage joinRoomMessage) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (joinRoomMessage == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isCanShowBarrage()) {
|
|
|
+ mTvJoinBarrage.setText(getString(R.string.enter_live_tip_str, TTLiveHelper.getMessageName(joinRoomMessage)));
|
|
|
+ showBarrageViewAnim(mFlJoinBarrage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示弹幕消息
|
|
|
+ */
|
|
|
+ private void showBarrageViewAnim(View targetView) {
|
|
|
+ if (mFlJoinBarrage.getVisibility() == View.VISIBLE || mFlSnapUpBarrage.getVisibility() == View.VISIBLE) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LiveRoomAnimatorHelper.getInstance().startBarrageViewAnimation(this, targetView);
|
|
|
+ hideBarrageView();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 隐藏弹幕消息
|
|
|
+ */
|
|
|
+ private void hideBarrageView() {
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (mFlJoinBarrage != null) {
|
|
|
+ mFlJoinBarrage.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ if (mFlSnapUpBarrage != null) {
|
|
|
+ mFlSnapUpBarrage.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, TTLiveConfig.LIVE_HIDE_BARRAGE_VIEW_TIME);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否显示弹幕消息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean isCanShowBarrage() {
|
|
|
+ if (isFullScreen()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return mFlJoinBarrage.getVisibility() != View.VISIBLE && mFlSnapUpBarrage.getVisibility() != View.VISIBLE;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void receiveSnapUpMessage(TCUserSnappingUpMessage onSnappingUpMessage) {
|
|
|
+ //收到抢购消息
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (onSnappingUpMessage == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isCanShowBarrage()) {
|
|
|
+ mTvSnapUpBarrage.setText(getString(R.string.live_snap_up_tip_str, TTLiveHelper.getMessageName(onSnappingUpMessage)));
|
|
|
+ showBarrageViewAnim(mFlSnapUpBarrage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void liveGoodsChange(String goodsContent) {
|
|
|
+ //直播间商品发生变化
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mShopCarDialog != null) {
|
|
|
+ mShopCarDialog.changeGoods(goodsContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onAddLikeMessage(TCSyncAddLikeMessage addLikeMessage) {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (addLikeMessage == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SendUserInfo sendUserInfo = addLikeMessage.getSendUserInfo();
|
|
|
+ if (sendUserInfo != null && isOwn(sendUserInfo.getSendUserId())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// if (addLikeMessage != null) {
|
|
|
+// if (mTvAddLikeCount != null) {
|
|
|
+// currentAddLikeCount = addLikeMessage.getCount();
|
|
|
+// updateAddLikeCountView();
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateAddLikeCountView(long count) {
|
|
|
+ this.currentAddLikeCount = count;
|
|
|
+ if (mTvAddLikeCount != null) {
|
|
|
+ mTvAddLikeCount.setText(getString(R.string.live_room_add_like_count_str, LiveMemberHelper.getStarsCountText(currentAddLikeCount)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncMemberCount(int count) {
|
|
|
+ //同步成员数量
|
|
|
+ Log.i("pq", "syncMemberCount" + count);
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// setPeopleCount(String.valueOf(count));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPeopleCount(String count) {
|
|
|
+ if (mTvNumPeople != null) {
|
|
|
+ mTvNumPeople.setText(String.format(Locale.getDefault(), "%s人", LiveMemberHelper.getMemberCountText(count)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserKickOutMsg(TCKickOutUserMessage userKickOutMessage) {
|
|
|
+ //用户被踢出消息
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (userKickOutMessage == null || !isOwn(userKickOutMessage.getTargetId())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String targetId = userKickOutMessage.getTargetId();
|
|
|
+ Log.i("pq", "receive kickOut msg targetId:" + targetId);
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isOwn(String targetUserId) {
|
|
|
+ return TextUtils.equals(mUserId, targetUserId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void seatResponse(TCUserSeatResponseMessage rcUserSeatResponseMessage) {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (rcUserSeatResponseMessage == null || !isOwn(rcUserSeatResponseMessage.getAudienceId())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (rcUserSeatResponseMessage != null) {
|
|
|
+ int type = rcUserSeatResponseMessage.getType();
|
|
|
+ if (type == LiveRoomMsgConstants.MIC_RESPONSE_AGREE) {
|
|
|
+ //主播同意
|
|
|
+// ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "主播同意连麦");
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.joinMic(mUserId, roomInfo.getUserSig());
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (type == LiveRoomMsgConstants.MIC_RESPONSE_DISAGREE) {
|
|
|
+ //主播拒绝
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_NORMAL);
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, getString(R.string.create_refuse_seat_tip));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onInviteSeatMic(TCUserSeatApplyMessage seatApplyMessage) {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (seatApplyMessage == null || !isOwn(seatApplyMessage.getAudienceId())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (seatApplyMessage.getType() == LiveRoomMsgConstants.MIC_ACTION_INVITE_SEAT_BY_CREATE) {
|
|
|
+ //主讲人邀请观众上麦
|
|
|
+ showInviteSeatDialog();
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (seatApplyMessage.getType() == LiveRoomMsgConstants.MIC_ACTION_CANCEL_INVITE_SEAT_BY_CREATE) {
|
|
|
+ //主讲人取消邀请观众上麦
|
|
|
+ if (mInviteSeatMicTipDialog != null) {
|
|
|
+ mInviteSeatMicTipDialog.dismiss();
|
|
|
+ }
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, getString(R.string.create_recall_seat_invite_tip));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (seatApplyMessage.getType() == LiveRoomMsgConstants.MIC_ACTION_CANCEL_SEAT_BY_CREATE) {
|
|
|
+ //主讲人讲观众抱下麦
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "主讲人断开连麦");
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.exitRoom();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showShopCarDialog() {
|
|
|
+ if (mShopCarDialog == null) {
|
|
|
+ mShopCarDialog = new LiveRoomShopCarDialog(this);
|
|
|
+ mShopCarDialog.setOnEventListener(new LiveRoomShopCarDialog.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void onOpenDetail(String url) {
|
|
|
+ mShopCarDialog.dismiss();
|
|
|
+ //发送XXX正在抢购消息
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_ON_SNAP_UP);
|
|
|
+// sendShowFloatWindowAction(SEND_JUMP_OTHER_PAGE_MSG);
|
|
|
+// ARouter.getInstance()
|
|
|
+// .build(ARouterConstace.ACTIVITY_HTML)
|
|
|
+// .withString(ARouterConstace.URL, url)
|
|
|
+// .withString(ARouterConstace.TITLE, "商品详情")
|
|
|
+// .navigation();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!mShopCarDialog.isShowing()) {
|
|
|
+ mShopCarDialog.show();
|
|
|
+ }
|
|
|
+ mShopCarDialog.setRoomId(mRoomId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showInviteSeatDialog() {
|
|
|
+ if (mInviteSeatMicTipDialog == null) {
|
|
|
+ mInviteSeatMicTipDialog = new LiveRoomInviteSeatMicTipDialog(this);
|
|
|
+ mInviteSeatMicTipDialog.setCancelable(false);
|
|
|
+ mInviteSeatMicTipDialog.setCanceledOnTouchOutside(false);
|
|
|
+ mInviteSeatMicTipDialog.setViewClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (v.getId() == R.id.tv_sure) {
|
|
|
+ //被邀请连麦->同意连麦
|
|
|
+ if (presenter != null && roomInfo != null) {
|
|
|
+ if (!checkMicMode2()) {
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_CANCEL_SEAT_AGREE_RESPONSE, getSpeakerId(), getSpeakerName());
|
|
|
+ presenter.joinMic(mUserId, roomInfo.getUserSig());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (v.getId() == R.id.tv_cancel) {
|
|
|
+ //被邀请连麦->拒绝连麦
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_CANCEL_SEAT_DISAGREE_RESPONSE, getSpeakerId(), getSpeakerName());
|
|
|
+ }
|
|
|
+ //重置一下连麦状态
|
|
|
+ handleCloseMicEvent();
|
|
|
+ }
|
|
|
+ mInviteSeatMicTipDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!mInviteSeatMicTipDialog.isShowing()) {
|
|
|
+ mInviteSeatMicTipDialog.show();
|
|
|
+ }
|
|
|
+ String defaultNick = "主讲人";
|
|
|
+ if (roomInfo != null && !TextUtils.isEmpty(roomInfo.speakerName)) {
|
|
|
+ defaultNick = roomInfo.speakerName;
|
|
|
+ }
|
|
|
+ mInviteSeatMicTipDialog.setContent(defaultNick);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserUnusualLogout(TCUserLogOutUnNormalMessage loginOutUnusualMessage) {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (loginOutUnusualMessage == null || !isOwn(loginOutUnusualMessage.getTargetId())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "直播加载异常,请退出重试");
|
|
|
+ Log.i("pq", "unusual logout");
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showLoading() {
|
|
|
+ showLiveStatusView(LIVE_STATUS_LOADING);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void hideLoading() {
|
|
|
+ hideLiveStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLivePause() {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ showLiveStatusView(LIVE_STATUS_IS_REST);
|
|
|
+ this.liveIsPause = true;
|
|
|
+// ToastUtil.getInstance().show(this, getString(R.string.live_is_pause_str));
|
|
|
+ handleCloseMicEvent();
|
|
|
+ if (mMicManagerDialog != null) {
|
|
|
+ mMicManagerDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changeBlackUserStatus(String userId, boolean isAddBlack) {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isOwn(userId)) {
|
|
|
+ isEnableAll = isAddBlack;
|
|
|
+ if (isEnableAll) {
|
|
|
+ //取消连麦
|
|
|
+ if (currentSeatStatus != LiveRoomMsgConstants.MIC_STATUS_NORMAL) {
|
|
|
+ handleCloseMicEvent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateInputTip();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateInputTip() {
|
|
|
+ if (tv_input == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isEnableAll) {
|
|
|
+ tv_input.setText(getString(R.string.unable_input_tip_str));
|
|
|
+ } else {
|
|
|
+ tv_input.setText(getString(R.string.live_input_tips_str));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUnderAllMic() {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isOnMic()) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.exitRoom();
|
|
|
+ }
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, getString(R.string.down_mic_by_create_tip));
|
|
|
+ if (presenter != null && roomInfo != null) {
|
|
|
+ presenter.buildUnderMicResponseMessage(mUserId, roomInfo.speakerId, roomInfo.speakerName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRefuseAllMicApply() {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mMicManagerDialog != null) {
|
|
|
+ mMicManagerDialog.dismiss();
|
|
|
+ }
|
|
|
+ if (isOnApplyMic()) {
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_NORMAL);
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, getString(R.string.create_refuse_seat_tip));
|
|
|
+ if (roomInfo != null) {
|
|
|
+ presenter.buildResponseMessage(mUserId, roomInfo.speakerId, roomInfo.speakerName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserStartPublish() {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void enterLiveRoomSuccess() {
|
|
|
+ //重置记录状态,等待回调触发准确值
|
|
|
+ hasMainStream = false;
|
|
|
+ hasSubStream = false;
|
|
|
+ if (mMLivePlayer != null) {
|
|
|
+ mMLivePlayer.stopPlay();
|
|
|
+ }
|
|
|
+ config3AParamsIfNeed();
|
|
|
+ muteAll(isMuteAll);
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_CONNECT_SUCCESS);
|
|
|
+ if (mMicManagerDialog != null) {
|
|
|
+ mMicManagerDialog.dismiss();
|
|
|
+ }
|
|
|
+ presenter.startPublish(mUserId);
|
|
|
+ notifyMicContainerAdd(mUserId);
|
|
|
+ changeMicStatus(mUserId, isMuteAllMic);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void config3AParamsIfNeed() {
|
|
|
+ if (!TextUtils.isEmpty(subjectId)) {
|
|
|
+ presenter.config3AParamsFromSubject(subjectId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean hasMainStream = false;//是否有主路流
|
|
|
+ private boolean hasSubStream = false;//是否有辅路流
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserVideoAvailable(String userId, boolean available) {
|
|
|
+ if (TextUtils.equals(userId, getSpeakerId())) {
|
|
|
+ Log.i(TAG, "onUserVideoAvailable:" + available);
|
|
|
+ hasMainStream = available;
|
|
|
+ startRemote();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserSubStreamAvailable(String userId, boolean available) {
|
|
|
+ if (TextUtils.equals(userId, getSpeakerId())) {
|
|
|
+ Log.i(TAG, "onUserSubStreamAvailable:" + available);
|
|
|
+ hasSubStream = available;
|
|
|
+ startRemote();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void startRemote() {
|
|
|
+ if (hasMainStream && hasSubStream) {
|
|
|
+ //主辅流都有的情况
|
|
|
+ subVideoView.setVisibility(View.VISIBLE);
|
|
|
+ presenter.startMainRemoteView(getSpeakerId(), isPcClientLive, subVideoView);
|
|
|
+ presenter.startSubRemoteView(getSpeakerId(), isPcClientLive, mVideoView);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (hasMainStream) {
|
|
|
+ //主流情况
|
|
|
+ subVideoView.setVisibility(View.GONE);
|
|
|
+ presenter.stopSubRemoteView(getSpeakerId());
|
|
|
+
|
|
|
+ presenter.startMainRemoteView(getSpeakerId(), isPcClientLive, mVideoView);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (hasSubStream) {
|
|
|
+ //单辅流情况
|
|
|
+ subVideoView.setVisibility(View.GONE);
|
|
|
+ presenter.stopMainRemoteView(getSpeakerId());
|
|
|
+ presenter.startSubRemoteView(getSpeakerId(), isPcClientLive, mVideoView);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void enterLiveRoomError() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onExitRoomSuccess() {
|
|
|
+ Log.i("pq", "onExitRoomSuccess");
|
|
|
+ currentSeatStatus = LiveRoomMsgConstants.MIC_STATUS_NORMAL;
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_NORMAL);
|
|
|
+ if (!TextUtils.isEmpty(mUserId)) {
|
|
|
+ notifyMicContainerDel(mUserId);
|
|
|
+ }
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.stopAllRemoteView(getSpeakerId());
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_DOWN_SEAT_MIC);
|
|
|
+ }
|
|
|
+ play();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStopPublishing() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPublishSuccess() {
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_CONNECT_SUCCESS);
|
|
|
+ if (mMicManagerDialog != null) {
|
|
|
+ mMicManagerDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRemoteUserEnterRoom(String userId) {
|
|
|
+ if (!TextUtils.equals(userId, getSpeakerId())) {
|
|
|
+ Log.i("pq", "onRemoteUserEnterRoom:" + userId);
|
|
|
+ notifyMicContainerAdd(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRemoteUserLeaveRoom(String userId, int reason) {
|
|
|
+ if (!TextUtils.equals(userId, getSpeakerId())) {
|
|
|
+ Log.i("pq", "onRemoteUserLeaveRoom:" + userId);
|
|
|
+ notifyMicContainerDel(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStatistics(TRTCStatistics statistics) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getFriendInfoSuccess(FriendInfoBean friendInfoBean) {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mLlMicContainer != null && friendInfoBean != null) {
|
|
|
+ String friendAvatar = "";
|
|
|
+ if (friendInfoBean.friend != null) {
|
|
|
+ friendAvatar = friendInfoBean.friend.avatar;
|
|
|
+ }
|
|
|
+ mLlMicContainer.updateTargetUserInfo(new TTUserInfo(friendInfoBean.friendId, friendInfoBean.friendNickname, !TextUtils.isEmpty(friendAvatar) ? Uri.parse(friendAvatar) : null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void receiveSEIMsg(String userId, byte[] data) {
|
|
|
+ if (TextUtils.equals(userId, getSpeakerId())) {
|
|
|
+// parseSeiMessage(new String(data));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onGroupAttributeChanged(String groupID, Map<String, String> groupAttributeMap) {
|
|
|
+ if (TextUtils.equals(groupID, mRoomId)) {
|
|
|
+ JSONObject jsonObject = new JSONObject(groupAttributeMap);
|
|
|
+ parseGroupAttribute(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onGroupCounterChanged(String groupID, String key, long newValue) {
|
|
|
+ if (TextUtils.equals(groupID, mRoomId)) {
|
|
|
+ if (TextUtils.equals(TTLiveConfig.LIVE_ROOM_LIKES_KEY, key)) {
|
|
|
+ //点赞数同步
|
|
|
+ Log.i("pq", "likes newValue:" + newValue);
|
|
|
+ updateAddLikeCountView(newValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getAllGroupCounterSuccess(Map<String, Long> map) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (map != null && map.size() > 0) {
|
|
|
+ //获取群点赞数
|
|
|
+ if (map.containsKey(TTLiveConfig.LIVE_ROOM_LIKES_KEY)) {
|
|
|
+ Long result = map.get(TTLiveConfig.LIVE_ROOM_LIKES_KEY);
|
|
|
+ if (result != null) {
|
|
|
+ updateAddLikeCountView(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onMicStatusControl(String userId, boolean muteMic) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!isOwn(userId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, muteMic ? "主讲人已将您的麦克风关闭" : "主讲人已将您的麦克风开启");
|
|
|
+ changeMicStatus(userId, muteMic);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUserAudioAvailable(String userId, boolean available) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mLlMicContainer != null) {
|
|
|
+ mLlMicContainer.updateTargetUserMicStatus(userId, available ? TTLiveConfig.LIVE_ROOM_MIC_STATUS_OFF_VALUE : TTLiveConfig.LIVE_ROOM_MIC_STATUS_ON_VALUE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLiveForceKick(TCLiveForceKickMessage messageContent) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (messageContent != null) {
|
|
|
+ ArrayList<String> targetIds = messageContent.getTargetIds();
|
|
|
+ if (targetIds != null && targetIds.size() > 0) {
|
|
|
+ //判断个人
|
|
|
+ for (int i = 0; i < targetIds.size(); i++) {
|
|
|
+ boolean isContainerOwner = isOwn(targetIds.get(i));
|
|
|
+ if (isContainerOwner) {
|
|
|
+ liveRoomOffline();
|
|
|
+ showLiveCourseStatusChangeTip(messageContent.getReason());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //全体
|
|
|
+ liveRoomOffline();
|
|
|
+ showLiveCourseStatusChangeTip(messageContent.getReason());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showLiveCourseStatusChangeTip(String tip) {
|
|
|
+ if (TextUtils.isEmpty(tip)) {
|
|
|
+ tip = "当前课程已调整,请退出直播间";
|
|
|
+ }
|
|
|
+ CommonConfirmDialog confirmDialog = new CommonConfirmDialog(this);
|
|
|
+ confirmDialog.show();
|
|
|
+ confirmDialog.setOnConfirmClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ confirmDialog.setContent(tip);
|
|
|
+ confirmDialog.hideCancel();
|
|
|
+ confirmDialog.setCancelable(false);
|
|
|
+ confirmDialog.setCanceledOnTouchOutside(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getAllGroupAttributesSuccess(Object o) {
|
|
|
+ Log.i("pq", "getAllGroupAttributesSuccess:" + o.toString());
|
|
|
+ if (o == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = new JSONObject(o.toString());
|
|
|
+ parseGroupAttribute(jsonObject);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void parseGroupAttribute(JSONObject groupAttributeJson) {
|
|
|
+ Log.i("pq", "group:" + groupAttributeJson.toString());
|
|
|
+ if (groupAttributeJson != null) {
|
|
|
+ //主播状态
|
|
|
+ checkAnchorStatus(groupAttributeJson);
|
|
|
+// //点赞数
|
|
|
+// getLikesFromAttributes(groupAttributeJson);
|
|
|
+ //人数
|
|
|
+ getMemberCountFromAttributes(groupAttributeJson);
|
|
|
+ //全局禁言状态
|
|
|
+ getGlobalBanStatus(groupAttributeJson);
|
|
|
+ //全员闭麦模式
|
|
|
+ getMuteAllMicStatus(groupAttributeJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getMuteAllMicStatus(JSONObject groupAttributeJson) {
|
|
|
+ String muteAllMicStatus = groupAttributeJson.optString(TTLiveConfig.LIVE_ROOM_MIC_STATUS_MODE_KEY);
|
|
|
+ if (!TextUtils.isEmpty(muteAllMicStatus)) {
|
|
|
+ Log.i("pq", " groupAttribute muteAllMicStatus:" + muteAllMicStatus);
|
|
|
+ boolean result = TextUtils.equals(muteAllMicStatus, TTLiveConfig.STATUS_ON);
|
|
|
+ if (result != isMuteAllMic) {
|
|
|
+ //有变化
|
|
|
+ if (isOnMic()) {
|
|
|
+ changeMicStatus(mUserId, result);
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, result ? "主讲人已将您的麦克风关闭" : "主讲人已将您的麦克风开启");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isMuteAllMic = result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getGlobalBanStatus(JSONObject groupAttributeJson) {
|
|
|
+ String globalBanStatus = groupAttributeJson.optString(TTLiveConfig.LIVE_ROOM_GLOBAL_BAN_KEY);
|
|
|
+ if (!TextUtils.isEmpty(globalBanStatus)) {
|
|
|
+ Log.i("pq", " groupAttribute globalBanStatus:" + globalBanStatus);
|
|
|
+ if (TextUtils.equals(globalBanStatus, TTLiveConfig.STATUS_ON)) {
|
|
|
+ //全局禁言开启
|
|
|
+ isEnableChat = true;
|
|
|
+ } else {
|
|
|
+ isEnableChat = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getCameraStatus(JSONObject groupAttributeJson) {
|
|
|
+ String cameraStatus = groupAttributeJson.optString(TTLiveConfig.LIVE_ROOM_ANCHOR_CAMERA_KEY);
|
|
|
+ if (!TextUtils.isEmpty(cameraStatus)) {
|
|
|
+ Log.i("pq", " groupAttribute cameraStatus:" + cameraStatus);
|
|
|
+ if (TextUtils.equals(cameraStatus, TTLiveConfig.STATUS_OFF)) {
|
|
|
+ //主播关闭摄像头
|
|
|
+ showLiveStatusView(LIVE_STATUS_IS_CLOSE_VIDEO);
|
|
|
+ } else {
|
|
|
+ hideLiveCameraStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getMemberCountFromAttributes(JSONObject groupAttributeMap) {
|
|
|
+ String member_online = groupAttributeMap.optString(TTLiveConfig.LIVE_ROOM_MEMBER_ONLINE_KEY);
|
|
|
+ Log.i("pq", "member_online:" + member_online);
|
|
|
+ if (!TextUtils.isEmpty(member_online)) {
|
|
|
+ setPeopleCount(member_online);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getLikesFromAttributes(JSONObject groupAttributeJson) {
|
|
|
+ String likes = groupAttributeJson.optString(TTLiveConfig.LIVE_ROOM_LIKES_KEY);
|
|
|
+ Log.i("pq", "likes:" + likes);
|
|
|
+ if (!TextUtils.isEmpty(likes)) {
|
|
|
+ try {
|
|
|
+ int i = Integer.parseInt(likes);
|
|
|
+ updateAddLikeCountView(i);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkAnchorStatus(JSONObject groupAttributeJson) {
|
|
|
+ if (liveIsFinish) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String anchorStatus = groupAttributeJson.optString(TTLiveConfig.LIVE_ROOM_LIVE_STATUS_KEY);
|
|
|
+ Log.i("pq", "checkAnchorStatus:" + anchorStatus);
|
|
|
+ if (TextUtils.isEmpty(anchorStatus)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (TextUtils.equals(anchorStatus, TTLiveConfig.STATUS_ON)) {
|
|
|
+ //如果在线
|
|
|
+ anchorIsOnline = true;
|
|
|
+ TCStudentLiveRoomActivity.this.liveIsPause = false;
|
|
|
+ play();
|
|
|
+ //主播摄像头状态
|
|
|
+ getCameraStatus(groupAttributeJson);
|
|
|
+ } else {
|
|
|
+ //不在线
|
|
|
+ anchorIsOnline = false;
|
|
|
+ showLiveStatusView(LIVE_STATUS_IS_REST);
|
|
|
+ mLlMicContainer.delAll();
|
|
|
+ handleCloseMicEvent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateMicIcon(int micStatus) {
|
|
|
+ //主线程更新
|
|
|
+ iv_mic.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ currentSeatStatus = micStatus;
|
|
|
+ if (micStatus == LiveRoomMsgConstants.MIC_STATUS_NORMAL) {
|
|
|
+ iv_mic.setImageResource(R.drawable.icon_mic_unconnect);
|
|
|
+ }
|
|
|
+ if (micStatus == LiveRoomMsgConstants.MIC_STATUS_CONNECTING) {
|
|
|
+ iv_mic.setImageResource(R.drawable.icon_mic_connecting);
|
|
|
+ }
|
|
|
+ if (micStatus == LiveRoomMsgConstants.MIC_STATUS_CONNECT_SUCCESS) {
|
|
|
+ iv_mic.setImageResource(R.drawable.icon_mic_conected);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭一些交互弹窗
|
|
|
+ */
|
|
|
+ private void hideDialog() {
|
|
|
+ //关闭邀请弹窗
|
|
|
+ if (mInviteSeatMicTipDialog != null && mInviteSeatMicTipDialog.isShowing()) {
|
|
|
+ mInviteSeatMicTipDialog.dismiss();
|
|
|
+ }
|
|
|
+ //关闭商品弹窗
|
|
|
+ if (mShopCarDialog != null && mShopCarDialog.isShowing()) {
|
|
|
+ mShopCarDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showLiveStatusView(int status) {
|
|
|
+ Log.i("pq", "showLiveStatusView:" + status);
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mViewLiveStatus == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //显示视频画面已经关闭页面
|
|
|
+ mViewLiveStatus.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mViewLiveStatus.setVisibility(status == LIVE_STATUS_IS_CLOSE_VIDEO ? View.GONE : View.VISIBLE);
|
|
|
+ if (status == LIVE_STATUS_IS_REST) {
|
|
|
+ group_loading.setVisibility(View.GONE);
|
|
|
+ tv_retry.setVisibility(View.GONE);
|
|
|
+ group_tip.setVisibility(View.VISIBLE);
|
|
|
+ hideLiveCameraStatus();
|
|
|
+ stopPlay();
|
|
|
+ mIvLiveStatusCenterIcon.setImageResource(R.drawable.icon_live_room_rest_bg);
|
|
|
+ mTvLiveStatusTipText.setText("休息一下,马上回来!");
|
|
|
+ mTvLiveStatusTipText.setTextSize(12);
|
|
|
+ mTvLiveStatusTipText.setBackgroundResource(R.drawable.shape_gray_14dp);
|
|
|
+ } else if (status == LIVE_STATUS_IS_CLOSE_VIDEO) {
|
|
|
+ viewLiveCameraStatus.setVisibility(View.VISIBLE);
|
|
|
+ mIvLiveStatusCameraCenterIcon.setImageResource(R.drawable.icon_live_room_close_video);
|
|
|
+ mTvLiveCameraStatusTipText.setText("主讲人已关闭画面!");
|
|
|
+ mTvLiveCameraStatusTipText.setTextSize(12);
|
|
|
+ mTvLiveCameraStatusTipText.setBackgroundResource(R.drawable.shape_gray_14dp);
|
|
|
+ } else if (status == LIVE_STATUS_IS_OFFLINE) {
|
|
|
+ group_loading.setVisibility(View.GONE);
|
|
|
+ tv_retry.setVisibility(View.GONE);
|
|
|
+ group_tip.setVisibility(View.VISIBLE);
|
|
|
+ hideLiveCameraStatus();
|
|
|
+ stopPlay();
|
|
|
+ mLlMicContainer.delAll();
|
|
|
+ mIvLiveStatusCenterIcon.setImageResource(R.drawable.icon_live_end_tip);
|
|
|
+ mTvLiveStatusTipText.setText("直播已结束!");
|
|
|
+ mTvLiveStatusTipText.setTextSize(14);
|
|
|
+ mTvLiveStatusTipText.setBackgroundColor(Color.TRANSPARENT);
|
|
|
+ } else if (status == LIVE_STATUS_LOADING) {
|
|
|
+ group_loading.setVisibility(View.VISIBLE);
|
|
|
+ group_tip.setVisibility(View.GONE);
|
|
|
+ tv_retry.setVisibility(View.GONE);
|
|
|
+ tv_loading.setText("视频加载中");
|
|
|
+ } else if (status == LIVE_STATUS_ERROR) {
|
|
|
+ group_loading.setVisibility(View.GONE);
|
|
|
+ tv_retry.setVisibility(View.VISIBLE);
|
|
|
+ group_tip.setVisibility(View.VISIBLE);
|
|
|
+ hideLiveCameraStatus();
|
|
|
+ stopPlay();
|
|
|
+ mIvLiveStatusCenterIcon.setImageResource(R.drawable.icon_live_room_close_video);
|
|
|
+ mTvLiveStatusTipText.setText("视频加载失败");
|
|
|
+ mTvLiveStatusTipText.setTextSize(14);
|
|
|
+ mTvLiveStatusTipText.setBackgroundResource(R.drawable.shape_gray_14dp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void stopPlay() {
|
|
|
+ if (mMLivePlayer != null) {
|
|
|
+ mMLivePlayer.stopPlay();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消连麦
|
|
|
+ */
|
|
|
+ private void handleCloseMicEvent() {
|
|
|
+ if (currentSeatStatus == LiveRoomMsgConstants.MIC_STATUS_CONNECTING) {
|
|
|
+ //连接中取消连接
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_CANCEL_SEAT_APPLY, getSpeakerId(), getSpeakerName());
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_NORMAL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (currentSeatStatus == LiveRoomMsgConstants.MIC_STATUS_CONNECT_SUCCESS) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.exitRoom();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ this.isOnResume = true;
|
|
|
+ unbindService();
|
|
|
+ //取消全部静音
|
|
|
+ if (!isMuteAll) {
|
|
|
+ muteAll(false);
|
|
|
+ }
|
|
|
+// if (mMLivePlayer != null) {
|
|
|
+// mMLivePlayer.resumeAudio();
|
|
|
+// mMLivePlayer.resumeVideo();
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onPause() {
|
|
|
+ super.onPause();
|
|
|
+ isOnResume = false;
|
|
|
+ sendShowFloatWindowAction(SEND_APP_BACKGROUND_MSG);
|
|
|
+// if (mMLivePlayer != null) {
|
|
|
+// mMLivePlayer.pauseVideo();
|
|
|
+// mMLivePlayer.pauseAudio();
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendShowFloatWindowAction(int what) {
|
|
|
+ android.os.Message message = android.os.Message.obtain();
|
|
|
+ message.what = what;
|
|
|
+ mHandler.sendMessageDelayed(message, SEND_SHOW_FLOAT_WINDOW_TIME);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected TTLiveRoomPresenter createPresenter() {
|
|
|
+ return new TTLiveRoomPresenter();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getRoomInfoSuccess(LiveRoomInfoBean roomInfo) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (roomInfo != null) {
|
|
|
+ this.roomInfo = roomInfo;
|
|
|
+ LOG.i(TAG,"getRoomInfoSuccess:"+roomInfo.toString());
|
|
|
+ String userSig = roomInfo.getUserSig();
|
|
|
+ if (!TextUtils.isEmpty(userSig)) {
|
|
|
+ presenter.connectIM(mUserId, userSig);
|
|
|
+// play();
|
|
|
+ }
|
|
|
+ isPcClientLive = TextUtils.equals(roomInfo.getOs(), "pc") || TextUtils.equals(roomInfo.getOs(), "client");
|
|
|
+ mMLivePlayer.setRenderFillMode(isPcClientLive ? V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFit : V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFill);
|
|
|
+ resetVideoContainer(!isPcClientLive);
|
|
|
+
|
|
|
+// if (!TextUtils.isEmpty(roomInfo.roomConfig)) {
|
|
|
+// try {
|
|
|
+// JSONObject jsonObject = new JSONObject(roomInfo.roomConfig);
|
|
|
+// //聊天模式
|
|
|
+// int chatCtrlMode = jsonObject.optInt("whether_chat", 0);
|
|
|
+// //连麦模式
|
|
|
+// int micCtrlMode = jsonObject.optInt("whether_mic", 0);
|
|
|
+// //购物车是否显示
|
|
|
+// int shopCarMode = jsonObject.optInt("whether_view_shop_cart", 0);
|
|
|
+// isEnableChat = chatCtrlMode == 1;
|
|
|
+// isEnableMic = micCtrlMode == 1;
|
|
|
+//
|
|
|
+// if (shopCarMode == 1) {
|
|
|
+// //隐藏购物车
|
|
|
+// mViewShopCarAnim.setVisibility(View.GONE);
|
|
|
+// mIvShopCar.setVisibility(View.GONE);
|
|
|
+// } else {
|
|
|
+// //显示购物车
|
|
|
+// mViewShopCarAnim.setVisibility(View.VISIBLE);
|
|
|
+// mIvShopCar.setVisibility(View.INVISIBLE);
|
|
|
+// }
|
|
|
+// } catch (JSONException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+ //黑名单模式
|
|
|
+ isEnableAll = roomInfo.blacklistFlag == 1;//1是黑名单 0否
|
|
|
+ updateInputTip();
|
|
|
+ updateAddLikeCountView(roomInfo.likeNum);
|
|
|
+
|
|
|
+ if (mTvNumPeople != null) {
|
|
|
+// int peopleCount = roomInfo.lookNum + 1;//加上自己
|
|
|
+ setPeopleCount(String.valueOf(roomInfo.lookNum));
|
|
|
+ }
|
|
|
+ if (mIvAvatar != null) {
|
|
|
+ //创建人头像
|
|
|
+ Glide.with(TCStudentLiveRoomActivity.this).load(roomInfo.speakerPic).placeholder(R.drawable.icon_default_head).error(R.drawable.icon_default_head).into(mIvAvatar);
|
|
|
+ }
|
|
|
+ if (mTvRoomCreateName != null) {
|
|
|
+ //创建人昵称
|
|
|
+ mTvRoomCreateName.setText(roomInfo.speakerName);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mMessageAdapter != null) {
|
|
|
+ mMessageAdapter.setRoomAuthorId(roomInfo.speakerId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getRoomInfoError(Throwable throwable) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void connectIMError(int errorCode, String errorMsg) {
|
|
|
+ hideLoading();
|
|
|
+ ToastUtil.getInstance().show(this, "加入直播间群聊异常,请退出重试");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void loginIMSuccess() {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.joinGroup(mRoomId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void joinGroupSuccess() {
|
|
|
+ hideLoading();
|
|
|
+ presenter.bindGroupListener();
|
|
|
+ presenter.getAllGroupAttributes(mRoomId);
|
|
|
+ presenter.getAllGroupCounter(mRoomId);
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_JOIN_ROOM);
|
|
|
+ presenter.notifyJoinRoomAction(mRoomId, mUserId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void play() {
|
|
|
+ if (roomInfo != null && roomInfo.getLiveRoomConfig() != null) {
|
|
|
+ if (isOnMic()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (liveIsPause || liveIsFinish || !anchorIsOnline) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mMLivePlayer.isPlaying() == 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //关键 player 对象与界面 view
|
|
|
+ mMLivePlayer.setRenderView(mVideoView);
|
|
|
+ LiveRoomInfoBean.LiveRoomConfigBean liveRoomConfig = roomInfo.getLiveRoomConfig();
|
|
|
+ String playUrl = getPlayUrl(liveRoomConfig.getPlayUrl(), roomInfo.getRoomId(), roomInfo.speakerImUserId);
|
|
|
+ Log.i("pq", "playUrl:" + playUrl);
|
|
|
+ showLiveStatusView(LIVE_STATUS_LOADING);
|
|
|
+ subVideoView.setVisibility(View.GONE);
|
|
|
+ mMLivePlayer.startLivePlay(playUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getPlayUrl(String domain, String roomId, String targetId) {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ stringBuilder.append("rtmp://")
|
|
|
+ .append(domain)
|
|
|
+ .append("/live/")
|
|
|
+ .append(roomId)
|
|
|
+ .append("_")
|
|
|
+ .append(targetId);
|
|
|
+// String url = "rtmp://cdn1.dayaedu.com/live/12233333_LIVE?12233333_LIVE";
|
|
|
+ return stringBuilder.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void joinGroupError(int code, String des) {
|
|
|
+ hideLoading();
|
|
|
+ Log.i(TAG, "joinGroupError code:" + code + "des" + des);
|
|
|
+ ToastUtil.getInstance().show(this, "加入直播群组失败,请退出重试");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addMessageContent(TTMessage ttMessage) {
|
|
|
+ //添加单条消息至页面
|
|
|
+ Log.i("pq", "收到需要显示msg:" + ttMessage);
|
|
|
+ //只处理直播间消息,以及本直播间消息
|
|
|
+ if (mMessageAdapter != null) {
|
|
|
+ mMessageAdapter.addMessage(ttMessage);
|
|
|
+ if (mRecyclerMsg != null && mLinearLayoutManager != null) {
|
|
|
+ mRecyclerMsg.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (isAutoScrollToLast) {
|
|
|
+ if (mRecyclerMsg != null) {
|
|
|
+ mRecyclerMsg.scrollToPosition(mMessageAdapter.getItemCount() - 1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Log.i("pq", "收到消息,不自动滚动");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isOnApplyMic() {
|
|
|
+ return currentSeatStatus == LiveRoomMsgConstants.MIC_STATUS_CONNECTING;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isOnMic() {
|
|
|
+ return currentSeatStatus == LiveRoomMsgConstants.MIC_STATUS_CONNECT_SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showMicManagerDialog() {
|
|
|
+ if (mMicManagerDialog == null) {
|
|
|
+ mMicManagerDialog = new LiveRoomMicManagerDialog(this);
|
|
|
+ mMicManagerDialog.setOnEventListener(new LiveRoomMicManagerDialog.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void onApplyMic() {
|
|
|
+ //申请连麦
|
|
|
+ handleMicEvent();
|
|
|
+ mMicManagerDialog.setMicStatus(LiveRoomMsgConstants.MIC_STATUS_CONNECTING);
|
|
|
+ mMicManagerDialog.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onApplyCancel() {
|
|
|
+ //取消申请连麦
|
|
|
+ handleMicEvent();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCloseMic() {
|
|
|
+ //关闭连麦
|
|
|
+ handleMicEvent();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!mMicManagerDialog.isShowing()) {
|
|
|
+ mMicManagerDialog.show();
|
|
|
+ }
|
|
|
+ if (roomInfo != null) {
|
|
|
+ mMicManagerDialog.setLiveTeacherInfo(roomInfo.speakerPic);
|
|
|
+ }
|
|
|
+ mMicManagerDialog.setMicStatus(currentSeatStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleMicEvent() {
|
|
|
+ if (currentSeatStatus == LiveRoomMsgConstants.MIC_STATUS_NORMAL) {
|
|
|
+ //未连麦状态 申请连麦
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.handleAction(LiveRoomMsgConstants.ACTION_SEND_SEAT_APPLY, getSpeakerId(), getSpeakerName());
|
|
|
+ }
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_CONNECTING);
|
|
|
+ } else {
|
|
|
+ //取消连麦
|
|
|
+ showCloseMicTipDialog();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getSpeakerId() {
|
|
|
+ if (roomInfo != null) {
|
|
|
+ return roomInfo.speakerId;
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getSpeakerName() {
|
|
|
+ if (roomInfo != null) {
|
|
|
+ return roomInfo.speakerName;
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showCloseMicTipDialog() {
|
|
|
+ if (mRoomCloseMicTipDialog == null) {
|
|
|
+ mRoomCloseMicTipDialog = new LiveRoomCloseMicTipDialog(this);
|
|
|
+ mRoomCloseMicTipDialog.setConfirmClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ handleCloseMicEvent();
|
|
|
+ mRoomCloseMicTipDialog.dismiss();
|
|
|
+ if (mMicManagerDialog != null) {
|
|
|
+ mMicManagerDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!mRoomCloseMicTipDialog.isShowing()) {
|
|
|
+ mRoomCloseMicTipDialog.show();
|
|
|
+ }
|
|
|
+ mRoomCloseMicTipDialog.setContent(getString(currentSeatStatus == LiveRoomMsgConstants.MIC_STATUS_CONNECTING ? R.string.cancel_seat_on_connecting : R.string.cancel_seat_on_connected));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查聊天模式
|
|
|
+ */
|
|
|
+ public boolean checkChatMode() {
|
|
|
+ if (liveIsFinish) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "直播已结束");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (isEnableAll) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "您已被管理员禁言");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (isEnableChat) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "管理员关闭聊天");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查mic模式
|
|
|
+ */
|
|
|
+ public boolean checkMicMode() {
|
|
|
+ if (!anchorIsOnline) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "老师暂停中,暂时无法接受申请");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (liveIsPause) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "老师暂停中,暂时无法接受申请");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (liveIsFinish) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "直播已结束");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (isEnableAll) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "您已被管理员禁言");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (isEnableMic) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "管理员关闭连麦申请");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查mic模式
|
|
|
+ */
|
|
|
+ public boolean checkMicMode2() {
|
|
|
+ if (!anchorIsOnline) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "老师暂停中,暂时无法接受申请");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (liveIsPause) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "老师暂停中,暂时无法接受申请");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (liveIsFinish) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "直播已结束");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (isEnableAll) {
|
|
|
+ ToastUtil.getInstance().show(TCStudentLiveRoomActivity.this, "您已被管理员禁言");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void finish() {
|
|
|
+ super.finish();
|
|
|
+ //前置通知离开接口
|
|
|
+ notifyLeave();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void notifyLeave() {
|
|
|
+ if (presenter != null) {
|
|
|
+ //通知离开房间
|
|
|
+ presenter.notifyLeaveRoomAction();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.release();
|
|
|
+ }
|
|
|
+ super.onDestroy();
|
|
|
+ if (mHandler != null) {
|
|
|
+ mHandler.removeCallbacksAndMessages(null);
|
|
|
+ }
|
|
|
+ if (mMLivePlayer != null) {
|
|
|
+ mMLivePlayer.stopPlay();
|
|
|
+ }
|
|
|
+ //取消动画
|
|
|
+ if (hideHeaderInfoAnim != null) {
|
|
|
+ hideHeaderInfoAnim.cancel();
|
|
|
+ hideHeaderInfoAnim = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (showHeaderInfoAnim != null) {
|
|
|
+ showHeaderInfoAnim.cancel();
|
|
|
+ showHeaderInfoAnim = null;
|
|
|
+ }
|
|
|
+ LiveRoomAnimatorHelper.getInstance().releaseAnimator();
|
|
|
+ LiveRoomAddLikeHelper.getInstance().release();
|
|
|
+ TRTCSdkManager.getInstance().release();
|
|
|
+ TCIMSdkManager.getInstance().quitGroup(mRoomId);
|
|
|
+ TCIMSdkManager.getInstance().release(mTIMSDKListener);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|