add[声望升级-修复BUG]

This commit is contained in:
Martin 2024-05-15 15:55:31 +08:00
parent cb376aa83a
commit 93dbee14b3
13 changed files with 156 additions and 84 deletions

View File

@ -268,6 +268,8 @@ public class Constants {
public static final int LIVE_SDK_KSY = 0;//金山推流
public static final int LIVE_SDK_TX = 1;//腾讯推流
public static final int LIVE_SDK_SW = 2;//声网
public static final int LINK_MIC_TYPE_NORMAL = 0;//观众与主播连麦
public static final int LINK_MIC_TYPE_ANCHOR = 1;//主播与主播连麦

View File

@ -25,6 +25,12 @@
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/videoFrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>

View File

@ -1499,4 +1499,5 @@
<string name="dragon_rule6">2.用戶關注主播並參與活動,將在倒計時五分鐘結束後瓜分活動金豆;</string>
<string name="dragon_rule7">3.此活動的最終解釋權歸PDLIVE所有。</string>
<string name="main_type_theater">短劇</string>
<string name="pking_over">主播正在PK稍後再試</string>
</resources>

View File

@ -1498,4 +1498,5 @@
<string name="dragon_rule6">2.用戶關注主播並參與活動,將在倒計時五分鐘結束後瓜分活動金豆;</string>
<string name="dragon_rule7">3.此活動的最終解釋權歸PDLIVE所有。</string>
<string name="main_type_theater">短劇</string>
<string name="pking_over">主播正在PK稍後再試</string>
</resources>

View File

@ -1495,5 +1495,6 @@
<string name="dragon_rule6">2.用戶關注主播並參與活動,將在倒計時五分鐘結束後瓜分活動金豆;</string>
<string name="dragon_rule7">3.此活動的最終解釋權歸PDLIVE所有。</string>
<string name="main_type_theater">短劇</string>
<string name="pking_over">主播正在PK稍後再試</string>
</resources>

View File

@ -1504,4 +1504,5 @@ Limited ride And limited avatar frame</string>
<string name="dragon_rule6">2.Users who follow the anchor and participate in the activity will divide the gold beans of the activity after the countdown of five minutes ends;</string>
<string name="dragon_rule7">3.The final interpretation of this activity belongs to PDLIVE.</string>
<string name="main_type_theater" >Theater</string>
<string name="pking_over">The anchor is in PK, please try again later</string>
</resources>

View File

@ -1,4 +1,4 @@
package com.yunbao.common.views.weight;
package io.agora.beautyapi.faceunity.agora;
import android.app.Activity;
import android.os.Bundle;
@ -7,6 +7,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.cardview.widget.CardView;
@ -19,6 +20,8 @@ import com.lzf.easyfloat.interfaces.OnInvokeView;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.dialog.HintDialog;
@ -26,10 +29,12 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.views.floatingview.APPEasyFloat;
import com.yunbao.common.views.floatingview.FloatingMagnetView;
import com.yunbao.common.views.floatingview.MagnetViewListener;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
@ -50,12 +55,14 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
private FloatCallbacks.Builder builder;
private String TAG = "LiveFloatView";
private TXLivePlayer mPlayer;
private FrameLayout videoFrameLayout;
private TXCloudVideoView videoView;
private SWAuManager swAuManager;
public static LiveFloatView getInstance() {
if (instance == null) {
instance = new LiveFloatView();
}
return instance;
}
@ -79,7 +86,17 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
cardParams.height = DpUtil.dp2px(224);
cardParams.width = DpUtil.dp2px(126);
}
TXCloudVideoView videoView = magnetView.findViewById(R.id.video_view);
if(mLiveSDK == Constants.LIVE_SDK_SW){
L.eSw("mLiveSDK == Constants.LIVE_S2222222222222222");
videoFrameLayout = magnetView.findViewById(R.id.videoFrameLayout);
swAuManager = SWAuManager.get();
swAuManager.setAudienceContainer(videoFrameLayout);
swAuManager.initRtcEngine( mContext);
swAuManager.setupRemoteVideo(Integer.parseInt(mLiveBean.getUid()));
//进入主播房间
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(mLiveBean.getUid()));
}else{
videoView = magnetView.findViewById(R.id.video_view);
mPlayer = new TXLivePlayer(mContext);
mPlayer.setPlayerView(videoView);
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
@ -99,19 +116,23 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
}
layout.setLayoutParams(cardParams);
}
}
@Override
public void onNetStatus(Bundle bundle) {
}
});
}
ViewClicksAntiShake.clicksAntiShake(magnetView.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if(mLiveSDK == Constants.LIVE_SDK_SW){
SWAuManager.get().exitChannelAll();
}else{
mPlayer.stopPlay(true);
}
APPEasyFloat.getInstance().dismiss(mContext);
if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) {
HintDialog fragment = new HintDialog();
@ -122,15 +143,22 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
}
}
});
if(mLiveSDK == Constants.LIVE_SDK_SW){
ViewClicksAntiShake.clicksAntiShake(videoFrameLayout, () -> {
mPlayer.stopPlay(true);
APPEasyFloat.getInstance().dismiss(mContext);
new Handler().post(liveCheck);
});
}else{
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
mPlayer.stopPlay(true);
APPEasyFloat.getInstance().dismiss(mContext);
new Handler().post(liveCheck);
});
}
}
@Override
public void onRemove() {
//
@ -164,7 +192,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
public LiveFloatView cacheLiveData(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) {
this.mLiveBean = mLiveBean;
this.mLiveType = mLiveType;
this.mLiveSDK = mLiveSDK;
this.mLiveSDK = Constants.LIVE_SDK_SW;
this.mLiveTypeVal = mLiveTypeVal;
return instance;
}
@ -202,7 +230,8 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
@Override
public void invoke(View view) {
TXCloudVideoView videoView = view.findViewById(R.id.video_view);
videoFrameLayout = view.findViewById(R.id.videoFrameLayout);
L.eSw("invoke(View view) invoke(View view) invoke(View view) invoke(View view) ");
CardView layout = view.findViewById(R.id.layout);
RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if (mLiveBean.getLandscape() == 1) {
@ -213,6 +242,16 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
cardParams.width = DpUtil.dp2px(126);
}
layout.setLayoutParams(cardParams);
if(mLiveSDK == Constants.LIVE_SDK_SW){
L.eSw("mLiveSDK == Constants.LIVE_SDK_SW mLive1111111");
swAuManager = SWAuManager.get();
swAuManager.setAudienceContainer(videoFrameLayout);
swAuManager.initRtcEngine( mContext);
swAuManager.setupRemoteVideo(Integer.parseInt(mLiveBean.getUid()));
//进入主播房间
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(mLiveBean.getUid()));
}else{
TXCloudVideoView videoView = view.findViewById(R.id.video_view);
mPlayer = new TXLivePlayer(mContext);
mPlayer.setPlayerView(videoView);
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
@ -240,12 +279,17 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
}
});
}
ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if(mLiveSDK == Constants.LIVE_SDK_SW){
SWAuManager.get().exitChannelAll();
}else{
mPlayer.stopPlay(true);
}
EasyFloat.dismiss("LiveFloatView", true);
if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) {
HintDialog fragment = new HintDialog();
@ -257,8 +301,11 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
}
});
ViewClicksAntiShake.clicksAntiShake(view, () -> {
if(mLiveSDK == Constants.LIVE_SDK_SW){
SWAuManager.get().exitChannelAll();
}else{
mPlayer.stopPlay(true);
}
new Handler().post(liveCheck);

View File

@ -309,8 +309,11 @@ public class SWAuManager extends BaseCacheManager {
* 退出所有的直播间
*/
public void exitChannelAll() {
L.eSw("exitChannelAll exitChannelAll exitChannelAll");
if(mRtcEngine!=null){
mRtcEngine.leaveChannel();
}
}
public static String getChannelName(String liveUid) {
if (liveUid.contains("g")) {

View File

@ -885,7 +885,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
}
});
} else {
ToastUtil.show("主播正在PK稍後再試");
ToastUtil.show(getString(R.string.pking_over));
}
}
}

View File

@ -68,6 +68,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Random;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@ -791,6 +792,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
* 退出直播间
*/
private void close() {
SWAuManager.get().exitChannelAll();
handler.removeCallbacks(runnable);
handler1.removeCallbacks(runnable1);
((LiveAudienceActivity) mContext).onBackPressed();

View File

@ -405,7 +405,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
}
/**
* 退出单人pk
*
@ -666,7 +665,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mStarted = false;
Bus.getOff(this);
EventBus.getDefault().unregister(this);
swAuManager.exitChannelAll();
//swAuManager.exitChannelAll();
L.e(TAG, "release------->");
}
@ -919,15 +918,26 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.requestLayout();
}
boolean isShow = false;
@Subscribe(threadMode = ThreadMode.MAIN)
public void onUpdata(String str) {
if ("UsertoRY".equals(str)) {
DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.mic_tag), new DialogUitl.SimpleCallback() {
//todo 新增dis监听
if (isShow) {
return;
}
isShow = true;
DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.mic_tag), new DialogUitl.SimpleCallback2() {
@Override
public void onCancelClick() {
isShow = false;
}
@Override
public void onConfirmClick(Dialog dialog, String content) {
UsertoRY();
dialog = null;
isShow = false;
}
});
@ -1425,6 +1435,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL_480] + videoFps[0] + ".flv");
}
}
private class ExoPlayerListener implements Player.Listener {
String TAG = "播放流";

View File

@ -82,7 +82,6 @@ import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.utils.formatBigNum;
import com.yunbao.common.views.weight.LiveFloatView;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
@ -122,6 +121,8 @@ import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.LiveFloatView;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
@ -326,7 +327,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void run() {
loading.setVisibility(View.GONE);
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
ToastUtil.show(mContext.getString(R.string.net_error) + " :500");//异常下播等待加载时间过了后弹出
//ToastUtil.show(mContext.getString(R.string.net_error) + " :500");//异常下播等待加载时间过了后弹出
}
};
@ -940,7 +941,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.removeFromParent();
mLiveRoomViewHolder.countDownTimerTrickery = null;
}
mLiveAudienceViewHolder = null;
mLivePlayViewHolder = null;
mLiveRoomViewHolder = null;
@ -1940,6 +1940,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (!isEnterRoom) {
return;
}
SWAuManager.get().exitChannelAll();
LiveNetManager.get(mContext)
.leaveRoomNew(leaveStream, leaveGroupId, new com.yunbao.common.http.base.HttpCallback<String>() {
@Override

View File

@ -13,8 +13,6 @@ import android.app.PendingIntent;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -57,7 +55,6 @@ import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.adapter.ViewPagerAdapter;
import com.yunbao.common.bean.AnchorRecommendItemModel;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.AnchorStartLiveBean;
import com.yunbao.common.bean.ChatRemarksBean;
@ -98,7 +95,6 @@ import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.GoogleUtils;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.LocationUtil;
import com.yunbao.common.utils.ProcessResultUtil;
@ -110,7 +106,6 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.APKUpdateCustomPopup;
import com.yunbao.common.views.AbsMainViewHolder;
import com.yunbao.common.views.floatingview.APPEasyFloat;
import com.yunbao.common.views.weight.LiveFloatView;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.utils.LiveStorge;
import com.yunbao.main.R;
@ -148,6 +143,7 @@ import java.util.concurrent.TimeUnit;
import cn.rongcloud.rtc.api.RCRTCConfig;
import cn.rongcloud.rtc.api.RCRTCEngine;
import io.agora.beautyapi.faceunity.agora.LiveFloatView;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.rong.imkit.config.RongConfigCenter;