diff --git a/FaceUnity/src/main/res/values/colors.xml b/FaceUnity/src/main/res/values/colors.xml index 5515d5610..deb27665a 100644 --- a/FaceUnity/src/main/res/values/colors.xml +++ b/FaceUnity/src/main/res/values/colors.xml @@ -1,8 +1,8 @@ - #3F51B5 - #303F9F - #FF4081 + #FF8D41 + #FF8D41 + #FF8D41 #050F14 diff --git a/common/src/main/java/com/yunbao/common/utils/BitmapUtil.java b/common/src/main/java/com/yunbao/common/utils/BitmapUtil.java index 9ea112281..6884368b4 100644 --- a/common/src/main/java/com/yunbao/common/utils/BitmapUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/BitmapUtil.java @@ -6,9 +6,11 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; +import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; import android.provider.MediaStore; import com.bumptech.glide.Glide; @@ -195,4 +197,24 @@ public class BitmapUtil { canvas.drawBitmap(bitmap, 0, 0, paint); return bm; } + + /** + * 镜像Bitmap + * + * @param bitmap + * @return + */ + public Bitmap convertMirror(Bitmap bitmap) { + int w = bitmap.getWidth(); + int h = bitmap.getHeight(); + Bitmap newb = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图 + Canvas cv = new Canvas(newb); + Matrix m = new Matrix(); + //m.postScale(1, -1); //镜像垂直翻转 + m.postScale(-1, 1); //镜像水平翻转 + //m.postRotate(-90); //旋转-90度 + Bitmap new2 = Bitmap.createBitmap(bitmap, 0, 0, w, h, m, true); + cv.drawBitmap(new2, new Rect(0, 0, new2.getWidth(), new2.getHeight()), new Rect(0, 0, w, h), null); + return newb; + } } diff --git a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java b/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java index 88ae20e94..8c68b9ff7 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java @@ -7,7 +7,10 @@ import android.text.TextUtils; import android.util.Log; import android.view.Gravity; import android.view.View; +import android.widget.RelativeLayout; +import androidx.appcompat.app.AppCompatActivity; +import androidx.cardview.widget.CardView; import androidx.fragment.app.FragmentActivity; import com.lzf.easyfloat.EasyFloat; @@ -17,6 +20,8 @@ import com.lzf.easyfloat.interfaces.OnInvokeView; import com.tencent.live2.V2TXLivePlayer; import com.tencent.live2.V2TXLivePlayerObserver; import com.tencent.live2.impl.V2TXLivePlayerImpl; +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; @@ -24,6 +29,8 @@ 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.DeviceUtils; +import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.floatingview.APPEasyFloat; @@ -51,7 +58,7 @@ public class LiveFloatView implements Function1 { private int mLiveTypeVal; private FloatCallbacks.Builder builder; private String TAG = "LiveFloatView"; - private V2TXLivePlayer mPlayer; + private TXLivePlayer mPlayer; public static LiveFloatView getInstance() { if (instance == null) { @@ -72,30 +79,37 @@ public class LiveFloatView implements Function1 { .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(130); + cardParams.width = DpUtil.dp2px(230); + } else { + cardParams.height = DpUtil.dp2px(224); + cardParams.width = DpUtil.dp2px(126); + } TXCloudVideoView videoView = magnetView.findViewById(R.id.video_view); - mPlayer = new V2TXLivePlayerImpl(mContext); - mPlayer.setRenderView(videoView); - mPlayer.startPlay(url); - mPlayer.setObserver(new V2TXLivePlayerObserver() { + mPlayer = new TXLivePlayer(mContext); + mPlayer.setPlayerView(videoView); + mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV); + mPlayer.setPlayListener(new ITXLivePlayListener() { @Override - public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { - super.onWarning(player, code, msg, extraInfo); - Log.e(TAG, msg + "==============" + code); + public void onPlayEvent(int event, Bundle param) { + float videoWidth = param.getInt("EVT_PARAM1", 0); + float videoHeight = param.getInt("EVT_PARAM2", 0); } @Override - public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { - super.onError(player, code, msg, extraInfo); - Log.e(TAG, msg + "==============" + code); + public void onNetStatus(Bundle bundle) { } }); ViewClicksAntiShake.clicksAntiShake(magnetView.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - mPlayer.stopPlay(); + mPlayer.stopPlay(true); APPEasyFloat.getInstance().dismiss(mContext); - if (IMLoginManager.get(mContext).isHint2()) { + if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) { HintDialog fragment = new HintDialog(); Bundle args = new Bundle(); args.putString("close", "1"); @@ -104,8 +118,8 @@ public class LiveFloatView implements Function1 { } } }); - ViewClicksAntiShake.clicksAntiShake(magnetView, () -> { - mPlayer.stopPlay(); + ViewClicksAntiShake.clicksAntiShake(videoView, () -> { + mPlayer.stopPlay(true); APPEasyFloat.getInstance().dismiss(mContext); new Handler().post(liveCheck); @@ -121,7 +135,7 @@ public class LiveFloatView implements Function1 { @Override public void dismiss() { if (mPlayer != null) - mPlayer.stopPlay(); + mPlayer.stopPlay(true); } }) .show(mContext); @@ -160,15 +174,14 @@ public class LiveFloatView implements Function1 { callback.invoke(aBoolean); } builder.dismiss(() -> { - if (mPlayer != null && mPlayer.isPlaying() == 1) { - mPlayer.stopPlay(); + if (mPlayer != null && mPlayer.isPlaying()) { + mPlayer.stopPlay(true); } return null; }); builder.hide(view12 -> { - if (mPlayer != null && mPlayer.isPlaying() == 1) { - mPlayer.pauseAudio(); - mPlayer.pauseVideo(); + if (mPlayer != null && mPlayer.isPlaying()) { + mPlayer.pause(); } return null; }); @@ -186,14 +199,23 @@ public class LiveFloatView implements Function1 { @Override public void invoke(View view) { TXCloudVideoView videoView = view.findViewById(R.id.video_view); - mPlayer = new V2TXLivePlayerImpl(mContext); - mPlayer.setRenderView(videoView); - mPlayer.startPlay(url); - + CardView layout = view.findViewById(R.id.layout); + mPlayer = new TXLivePlayer(mContext); + mPlayer.setPlayerView(videoView); + mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV); + RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams(); + if (mLiveBean.getLandscape() == 1) { + cardParams.height = DpUtil.dp2px(130); + cardParams.width = DpUtil.dp2px(230); + } else { + cardParams.height = DpUtil.dp2px(224); + cardParams.width = DpUtil.dp2px(126); + } + layout.setLayoutParams(cardParams); ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - mPlayer.stopPlay(); + mPlayer.stopPlay(true); EasyFloat.dismiss("LiveFloatView", true); if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) { HintDialog fragment = new HintDialog(); @@ -206,7 +228,7 @@ public class LiveFloatView implements Function1 { }); ViewClicksAntiShake.clicksAntiShake(view, () -> { - mPlayer.stopPlay(); + mPlayer.stopPlay(true); new Handler().post(liveCheck); diff --git a/common/src/main/res/layout/view_flaot_live.xml b/common/src/main/res/layout/view_flaot_live.xml index e97d21e66..5b1d2d4db 100644 --- a/common/src/main/res/layout/view_flaot_live.xml +++ b/common/src/main/res/layout/view_flaot_live.xml @@ -1,10 +1,11 @@ - -