修复:直播准备页面切换摄像头可能失效问题

修复:直播准备页面美颜-美肤可能无效问题
This commit is contained in:
zlzw 2022-11-09 15:09:37 +08:00
parent 1eee54fef1
commit 8eae2c29ae
5 changed files with 74 additions and 50 deletions

View File

@ -19,6 +19,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
@ -57,6 +58,7 @@ import com.yunbao.common.utils.LogUtil;
import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.faceunity.FaceManager;
import com.yunbao.live.R;
import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.bean.LiveKsyConfigBean;
@ -121,7 +123,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
private ViewGroup mRoot;
private ViewGroup mContainerWrap;
public static LivePushRyViewHolder mLivePushViewHolder;
public LivePushRyViewHolder mLivePushViewHolder;
public LiveNewReadyRyViewHolder mLiveReadyViewHolder;
public static LiveRyAnchorViewHolder mLiveAnchorViewHolder;
private LiveMusicViewHolder mLiveMusicViewHolder;
@ -139,6 +141,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
public static boolean PKing = false;
public static int pk_nub;
public static int backIndex = 0;//0=未判断1=已判断
private FaceManager manager;
@Override
@ -151,6 +154,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
super.main();
Bus.getOn(this);
Intent intent = getIntent();
initFaceManager();
mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY);
mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG);
L.e(TAG, "直播sdk----->" + (mLiveSDK == Constants.LIVE_SDK_KSY ? "金山云" : "腾讯云"));
@ -177,8 +181,10 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mContainer = (ViewGroup) findViewById(R.id.container);
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePushViewHolder, true, mContainer);
//添加开播前设置控件
mLiveReadyViewHolder = new LiveNewReadyRyViewHolder(mContext, mContainer, mLiveSDK);
mLiveReadyViewHolder.setManager(manager);
mLiveReadyViewHolder.addToParent();
mLiveReadyViewHolder.subscribeActivityLifeCycle();
mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer);
@ -208,6 +214,12 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
private void initFaceManager() {
manager = new FaceManager();
manager.initFURender(mContext);
manager.drawRongFrame(mContext);
}
public boolean isStartPreview() {
return mStartPreview;
}
@ -584,6 +596,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLiveReadyViewHolder = null;
if (mLiveRoomViewHolder == null) {
mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager());
mLiveRoomViewHolder.setManager(manager);
mLiveRoomViewHolder.addToParent();
mLiveRoomViewHolder.subscribeActivityLifeCycle();
mLiveRoomViewHolder.setLiveInfo(mLiveUid, mStream, obj.getIntValue("userlist_time") * 1000);
@ -609,6 +622,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
mLiveBottomViewHolder = mLiveAnchorViewHolder;
mSocketRyClient = new SocketRyClient(mLiveUid, this);
mSocketRyClient.setLivePushRyViewHolder(mLivePushViewHolder);
CommonAppContext.Ingroup = 1;
if (mLiveLinkMicPresenter != null) {
@ -837,9 +851,21 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
super.release();
}
private boolean isKeyBack=false;
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK){
isKeyBack=true;
finish();
}
return super.onKeyUp(keyCode, event);
}
@Override
protected void onDestroy() {
if (manager != null) {
manager.release();
}
LiveHttpUtil.cancel(LiveHttpConsts.ANCHOR_CHECK_LIVE);
super.onDestroy();
if (mLivePushViewHolder != null) {
@ -865,7 +891,9 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLiveRoomViewHolder.anchorPause();
}
super.onPause();
sendSystemMessage(WordUtil.getString(R.string.live_anchor_leave));
if(isKeyBack) {
sendSystemMessage(WordUtil.getString(R.string.live_anchor_leave));
}
mPaused = true;
}

View File

@ -43,19 +43,10 @@ public class LiveFunctionAdapter extends RecyclerView.Adapter<LiveFunctionAdapte
}
if (LiveRyAnchorActivity.mLivePushViewHolder != null) {
//LiveRyAnchorActivity.leave
if (leave == 0) {
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave, R.string.live_zslk));
} else {
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave_p, R.string.live_zslk1));
}
}else{
if(leave == 0) {
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave, R.string.live_zslk));
}else{
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave_p, R.string.live_zslk1));
}
if (leave == 0) {
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave, R.string.live_zslk));
} else {
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave_p, R.string.live_zslk1));
}
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_WISHLIST, R.mipmap.icon_xinyuandan, R.string.live_wishlist));

View File

@ -90,6 +90,12 @@ public class SocketRyClient {
}
public void setLivePushRyViewHolder(LivePushRyViewHolder livePushRyViewHolder) {
if (mSocketHandler != null) {
mSocketHandler.setLivePushRyViewHolder(livePushRyViewHolder);
}
}
public void disConnect() {
// V2TIMManager.getInstance().
mLiveUid = null;
@ -100,6 +106,7 @@ public class SocketRyClient {
public static class SocketHandler extends Handler {
private static SocketMessageListener mListener;
private LivePushRyViewHolder livePushRyViewHolder;
private static String mLiveUid;
public SocketHandler(SocketMessageListener listener) {
@ -108,7 +115,10 @@ public class SocketRyClient {
public void setLiveUid(String liveUid) {
mLiveUid = liveUid;
}
public void setLivePushRyViewHolder(LivePushRyViewHolder livePushRyViewHolder) {
this.livePushRyViewHolder = livePushRyViewHolder;
}
@Override
@ -246,7 +256,7 @@ public class SocketRyClient {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
}
LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time"));
if (LiveRyAnchorActivity.mLivePushViewHolder == null) {
if (livePushRyViewHolder == null) {
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
}

View File

@ -54,7 +54,7 @@ import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream;
public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener {
private ConstraintLayout mAvatar,mRootView;
private ConstraintLayout mAvatar, mRootView;
private TextView mCoverText;
private EditText mEditTitle;
private ProcessImageUtil mImageUtil;
@ -120,7 +120,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
mLiveClass = (TextView) findViewById(R.id.live_class);
mLiveTypeTextView = (TextView) findViewById(R.id.text_room_type);
mLiveWishListTextView = (TextView) findViewById(R.id.text_wishlist);
faceTextView=(TextView)findViewById(R.id.faceTextView);
faceTextView = (TextView) findViewById(R.id.faceTextView);
mImageUtil = ((LiveActivity) mContext).getProcessImageUtil();
mImageUtil.setImageResultCallback(new ImageResultCallback() {
@ -163,27 +163,29 @@ 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);
manager = new FaceManager();
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
final Handler handler = new Handler(Looper.getMainLooper());
if (manager != null) {
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void onFaceChanged(int num) {
handler.post(() -> {
if (num == 0) {
faceTextView.setVisibility(View.VISIBLE);
} else {
faceTextView.setVisibility(View.GONE);
}
});
}
});
//新美颜
manager.initFURender(mContext);
manager.drawRongFrame(mContext);
setFaceUnity(true);
@Override
public void onFaceChanged(int num) {
handler.post(() -> {
if (num == 0) {
faceTextView.setVisibility(View.VISIBLE);
} else {
faceTextView.setVisibility(View.GONE);
}
});
}
});
//新美颜
setFaceUnity(true);
}
}
public void setManager(FaceManager manager) {
this.manager = manager;
}
@Override
public void onClick(View v) {
@ -229,7 +231,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
if (mContext instanceof LiveRyAnchorActivity) {
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
mRootView.setVisibility(View.INVISIBLE);
if(init){
if (init) {
fragment.dismiss();
}
}
@ -341,8 +343,8 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
*/
private void beauty() {
((LiveRyAnchorActivity) mContext).beauty();
// Intent intent = new Intent(mContext, Beauty360Activity3.class);
// mContext.startActivity(intent);
// Intent intent = new Intent(mContext, Beauty360Activity3.class);
// mContext.startActivity(intent);
}
@ -524,8 +526,5 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
@Override
public void onDestroy() {
LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM);
if(manager!=null) {
manager.release();
}
}
}

View File

@ -2857,19 +2857,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mChatRecyclerView.setLayoutParams(params1);
}
public void setManager(FaceManager manager) {
this.manager = manager;
}
/**
* 启动美颜SDK
*/
public void startFace() {
manager = new FaceManager();
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
@Override
public void onFaceChanged(int num) {
}
});
manager.initFURender(mContext);
manager.drawRongFrame(mContext);
}
/**