add[声望升级-修复BUG]
This commit is contained in:
@@ -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;//主播与主播连麦
|
||||
|
||||
@@ -1,307 +0,0 @@
|
||||
package com.yunbao.common.views.weight;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.lzf.easyfloat.enums.ShowPattern;
|
||||
import com.lzf.easyfloat.interfaces.FloatCallbacks;
|
||||
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.R;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.dialog.HintDialog;
|
||||
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.RouteUtil;
|
||||
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||
import com.yunbao.common.views.floatingview.FloatingMagnetView;
|
||||
import com.yunbao.common.views.floatingview.MagnetViewListener;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
/**
|
||||
* 直播间悬浮窗管理
|
||||
*/
|
||||
public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
|
||||
private static LiveFloatView instance;
|
||||
private LiveOnInvokeView liveOnInvokeView = null;
|
||||
private Activity mContext;
|
||||
private String url;
|
||||
private LiveBean mLiveBean;
|
||||
private int mLiveType;
|
||||
private int mLiveSDK;
|
||||
private int mLiveTypeVal;
|
||||
private FloatCallbacks.Builder builder;
|
||||
private String TAG = "LiveFloatView";
|
||||
private TXLivePlayer mPlayer;
|
||||
|
||||
public static LiveFloatView getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LiveFloatView();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void builderFloat(Activity mContext, String url, Class<?> back) {
|
||||
this.mContext = mContext;
|
||||
this.url = url;
|
||||
if (TextUtils.isEmpty(url)) return;
|
||||
APPEasyFloat.getInstance().layout(R.layout.view_flaot_live)
|
||||
.dragEnable(true)
|
||||
.setAutoMoveToEdge(true)
|
||||
.black(back)
|
||||
.setMagnetViewListener(new MagnetViewListener() {
|
||||
@Override
|
||||
public void invoke(FloatingMagnetView magnetView) {
|
||||
CardView layout = magnetView.findViewById(R.id.layout);
|
||||
RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams();
|
||||
if (mLiveBean.getLandscape() == 1) {
|
||||
cardParams.height = DpUtil.dp2px(190);
|
||||
cardParams.width = DpUtil.dp2px(255);
|
||||
} else {
|
||||
cardParams.height = DpUtil.dp2px(224);
|
||||
cardParams.width = DpUtil.dp2px(126);
|
||||
}
|
||||
TXCloudVideoView videoView = magnetView.findViewById(R.id.video_view);
|
||||
mPlayer = new TXLivePlayer(mContext);
|
||||
mPlayer.setPlayerView(videoView);
|
||||
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
|
||||
mPlayer.setPlayListener(new ITXLivePlayListener() {
|
||||
@Override
|
||||
public void onPlayEvent(int event, Bundle param) {
|
||||
float videoWidth = param.getInt("EVT_PARAM1", 0);
|
||||
float videoHeight = param.getInt("EVT_PARAM2", 0);
|
||||
Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
|
||||
if (mLiveBean.getLandscape() != 1){
|
||||
if (videoWidth > 720) {
|
||||
cardParams.height = DpUtil.dp2px(190);
|
||||
cardParams.width = DpUtil.dp2px(255);
|
||||
} else {
|
||||
cardParams.height = DpUtil.dp2px(224);
|
||||
cardParams.width = DpUtil.dp2px(126);
|
||||
}
|
||||
layout.setLayoutParams(cardParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetStatus(Bundle bundle) {
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(magnetView.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
mPlayer.stopPlay(true);
|
||||
APPEasyFloat.getInstance().dismiss(mContext);
|
||||
if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) {
|
||||
HintDialog fragment = new HintDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("close", "1");
|
||||
fragment.setArguments(args);
|
||||
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog");
|
||||
}
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
|
||||
mPlayer.stopPlay(true);
|
||||
APPEasyFloat.getInstance().dismiss(mContext);
|
||||
new Handler().post(liveCheck);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove() {
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (mPlayer != null)
|
||||
mPlayer.stopPlay(true);
|
||||
}
|
||||
})
|
||||
.show(mContext);
|
||||
|
||||
}
|
||||
|
||||
public void builderSystemFloat(Activity mContext, String url) {
|
||||
liveOnInvokeView = new LiveOnInvokeView();
|
||||
this.mContext = mContext;
|
||||
this.url = url;
|
||||
if (TextUtils.isEmpty(url)) return;
|
||||
EasyFloat.with(mContext)
|
||||
.setTag(TAG)
|
||||
.setLayout(R.layout.view_flaot_live, liveOnInvokeView)
|
||||
.setShowPattern(ShowPattern.ALL_TIME)
|
||||
.setFilter()
|
||||
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
|
||||
.registerCallback(this)
|
||||
.show();
|
||||
}
|
||||
|
||||
public LiveFloatView cacheLiveData(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) {
|
||||
this.mLiveBean = mLiveBean;
|
||||
this.mLiveType = mLiveType;
|
||||
this.mLiveSDK = mLiveSDK;
|
||||
this.mLiveTypeVal = mLiveTypeVal;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unit invoke(FloatCallbacks.Builder builder) {
|
||||
this.builder = builder;
|
||||
builder.createResult((aBoolean, s, view) -> {
|
||||
Log.e("LiveFloatView", "aBoolean:" + aBoolean + "---------------------s:" + s);
|
||||
if (callback != null) {
|
||||
callback.invoke(aBoolean);
|
||||
}
|
||||
builder.dismiss(() -> {
|
||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
||||
mPlayer.stopPlay(true);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
builder.hide(view12 -> {
|
||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
||||
mPlayer.pause();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 悬浮窗布局管理
|
||||
*/
|
||||
private class LiveOnInvokeView implements OnInvokeView {
|
||||
|
||||
@Override
|
||||
public void invoke(View view) {
|
||||
TXCloudVideoView videoView = view.findViewById(R.id.video_view);
|
||||
CardView layout = view.findViewById(R.id.layout);
|
||||
RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams();
|
||||
if (mLiveBean.getLandscape() == 1) {
|
||||
cardParams.height = DpUtil.dp2px(190);
|
||||
cardParams.width = DpUtil.dp2px(255);
|
||||
} else {
|
||||
cardParams.height = DpUtil.dp2px(224);
|
||||
cardParams.width = DpUtil.dp2px(126);
|
||||
}
|
||||
layout.setLayoutParams(cardParams);
|
||||
mPlayer = new TXLivePlayer(mContext);
|
||||
mPlayer.setPlayerView(videoView);
|
||||
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
|
||||
mPlayer.setPlayListener(new ITXLivePlayListener() {
|
||||
@Override
|
||||
public void onPlayEvent(int event, Bundle param) {
|
||||
float videoWidth = param.getInt("EVT_PARAM1", 0);
|
||||
float videoHeight = param.getInt("EVT_PARAM2", 0);
|
||||
Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
|
||||
if (mLiveBean.getLandscape() != 1){
|
||||
if (videoWidth > 720) {
|
||||
cardParams.height = DpUtil.dp2px(190);
|
||||
cardParams.width = DpUtil.dp2px(255);
|
||||
} else {
|
||||
cardParams.height = DpUtil.dp2px(224);
|
||||
cardParams.width = DpUtil.dp2px(126);
|
||||
}
|
||||
layout.setLayoutParams(cardParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetStatus(Bundle bundle) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
mPlayer.stopPlay(true);
|
||||
EasyFloat.dismiss("LiveFloatView", true);
|
||||
if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) {
|
||||
HintDialog fragment = new HintDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("close", "1");
|
||||
fragment.setArguments(args);
|
||||
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog");
|
||||
}
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(view, () -> {
|
||||
|
||||
mPlayer.stopPlay(true);
|
||||
new Handler().post(liveCheck);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private LiveFloatViewCallback callback;
|
||||
|
||||
public LiveFloatView setCallback(LiveFloatViewCallback callback) {
|
||||
this.callback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface LiveFloatViewCallback {
|
||||
void invoke(Boolean aBoolean);
|
||||
|
||||
}
|
||||
|
||||
private Runnable liveCheck = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HttpClient.getInstance().get("Live.checkLive", "")
|
||||
.params("liveuid", mLiveBean.getUid())
|
||||
.params("stream", mLiveBean.getStream())
|
||||
.execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
|
||||
RouteUtil.forwardLiveAudienceActivity(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal);
|
||||
|
||||
} else {
|
||||
//判断是否有直播悬浮窗,有直接关闭
|
||||
if (EasyFloat.isShow("LiveFloatView")) {
|
||||
EasyFloat.dismiss("LiveFloatView", true);
|
||||
} else {
|
||||
APPEasyFloat.getInstance().dismiss(mContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user