1、删除腾讯IM、腾讯播放器jar+so文件

2、注释+删除使用了腾讯SDK的地方
This commit is contained in:
老皮 2024-09-25 15:13:50 +08:00
parent 9b4a2bd5e5
commit 80892b14e4
74 changed files with 325 additions and 3358 deletions

View File

@ -27,10 +27,6 @@ import com.fm.openinstall.OpenInstall;
import com.google.gson.Gson;
import com.yunbao.common.utils.DebugUtils;
import com.yunbao.common.utils.LogUtils;
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.BuildConfig;
@ -282,7 +278,7 @@ public class AppContext extends CommonAppContext {
});
//监听im消息
/* //监听im消息
V2TIMManager.getInstance().addSimpleMsgListener(new V2TIMSimpleMsgListener() {
@Override
public void onRecvGroupTextMessage(String msgID, String groupID, V2TIMGroupMemberInfo sender, String text) {
@ -308,7 +304,7 @@ public class AppContext extends CommonAppContext {
}
}
});
});*/
configSPApp();
//初始化美颜SDK

View File

@ -42,12 +42,6 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.google.android.exoplayer2.video.VideoSize;
import com.shayu.phonelive.AppContext;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLiveBase;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.tencent.ugc.TXUGCBase;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.AdBean;
@ -421,8 +415,6 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
//sdk接口动态加载so TXLiveBase.setLibraryPath(); https://brands.cnblogs.com/tencentcloud/p/6137
TXLiveBase.getInstance().setLicence(LauncherActivity.this, bean.getTxVideoUgcLicenceUrl(), bean.getTxVideoUgcKey());
TXUGCBase.getInstance().setLicence(LauncherActivity.this, bean.getTxPlayUgcLicenceUrl(), bean.getTxVideoUgcKey());
String adInfo = bean.getAdInfo();
if (!TextUtils.isEmpty(adInfo)) {

View File

@ -174,9 +174,6 @@ dependencies {
api 'com.squareup.picasso:picasso:2.5.2'
api "com.immomo.cosmos.mediax:beautyutils:2.2.1_01071700"
// liteavsdk.jarlibtxffmpeg.solibliteavsdk.solibtxsoundtouch.so https://cloud.tencent.com/document/product/881/81205
api files('libs/liteavsdk.jar')
//im libImSDK.so https://cloud.tencent.com/document/product/269/75283
api 'com.tencent.imsdk:imsdk-plus:5.4.666'
api 'com.xw.repo:bubbleseekbar:3.20-lite'

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,11 +9,6 @@ import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.widget.RelativeLayout;
import com.tencent.rtmp.ITXVodPlayListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXVodPlayConfig;
import com.tencent.rtmp.TXVodPlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.R;
import com.yunbao.common.bean.ImageEntity;
@ -23,13 +18,13 @@ import java.util.List;
* Created by Haoxuan Chen on 2022/05/4.
* Description:查看视频
*/
public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListener, View.OnClickListener {
public class PreviewVideoActivity extends AbsActivity implements View.OnClickListener {
View v_back;
private List<ImageEntity> mSelectedImages;
private TXCloudVideoView mTXCloudVideoView;
private TXVodPlayer mPlayer;
private TXVodPlayConfig mTXVodPlayConfig;
// private TXCloudVideoView mTXCloudVideoView;
// private TXVodPlayer mPlayer;
// private TXVodPlayConfig mTXVodPlayConfig;
private boolean mStartPlay;
private String mCachePath;
private boolean mPaused;//生命周期暂停
@ -43,7 +38,7 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
public void main(Bundle savedInstanceState) {
mSelectedImages = getIntent().getParcelableArrayListExtra("preview_images");
v_back = findViewById(R.id.v_back);
mTXCloudVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
// mTXCloudVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
v_back.setOnClickListener(new View.OnClickListener() {
@Override
@ -65,7 +60,7 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
*/
private void playAdVideo() {
mCachePath = mContext.getCacheDir().getAbsolutePath();
mTXCloudVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
/* mTXCloudVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
mPlayer = new TXVodPlayer(mContext);
mTXVodPlayConfig = new TXVodPlayConfig();
@ -74,7 +69,7 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
mPlayer.setConfig(mTXVodPlayConfig);
mPlayer.setAutoPlay(true);
mPlayer.setVodListener(this);
mPlayer.setPlayerView(mTXCloudVideoView);
mPlayer.setPlayerView(mTXCloudVideoView);*/
findViewById(R.id.root).setOnClickListener(this);
mVideoCover = findViewById(R.id.video_cover);
mPlayBtn = findViewById(R.id.btn_play);
@ -104,7 +99,7 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
if (TextUtils.isEmpty(url)) {
return;
}
if (mTXVodPlayConfig == null) {
/* if (mTXVodPlayConfig == null) {
mTXVodPlayConfig = new TXVodPlayConfig();
mTXVodPlayConfig.setMaxCacheItems(15);
mTXVodPlayConfig.setProgressInterval(200);
@ -117,14 +112,14 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
mPlayer.setConfig(mTXVodPlayConfig);
if (mPlayer != null) {
mPlayer.startPlay(url);
}
}*/
}
/**
* 获取到视频宽高回调
*/
public void onVideoSizeChanged(float videoWidth, float videoHeight) {
if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
/*if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mTXCloudVideoView.getLayoutParams();
int targetH = 0;
if (videoWidth / videoHeight > 0.5625f) {//横屏 9:16=0.5625
@ -139,26 +134,26 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
if (mVideoCover != null && mVideoCover.getVisibility() == View.VISIBLE) {
mVideoCover.setVisibility(View.INVISIBLE);
}
}
}*/
}
/**
* 停止播放
*/
public void stopPlay() {
if (mPlayer != null) {
/* if (mPlayer != null) {
mPlayer.stopPlay(false);
}
}*/
}
/**
* 循环播放
*/
private void replay() {
if (mPlayer != null) {
/* if (mPlayer != null) {
mPlayer.seek(0);
mPlayer.resume();
}
}*/
}
/**
@ -194,13 +189,13 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
if (!mStartPlay) {
return;
}
if (mPlayer != null) {
/* if (mPlayer != null) {
if (mClickPaused) {
mPlayer.resume();
} else {
mPlayer.pause();
}
}
}*/
mClickPaused = !mClickPaused;
if (mClickPaused) {
showPlayBtn();
@ -212,52 +207,13 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
}
}
/**
* 播放器事件回调
*/
@Override
public void onPlayEvent(TXVodPlayer txVodPlayer, int e, Bundle bundle) {
switch (e) {
case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://加载完成开始播放的回调
mStartPlay = true;
if (mActionListener != null) {
mActionListener.onPlayBegin();
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_LOADING: //开始加载的回调
if (mActionListener != null) {
mActionListener.onPlayLoading();
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_END://获取到视频播放完毕的回调
replay();
break;
case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://获取到视频首帧回调
if (mActionListener != null) {
mActionListener.onFirstFrame();
}
if (mPaused && mPlayer != null) {
mPlayer.pause();
}
break;
case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取到视频宽高回调
onVideoSizeChanged(bundle.getInt("EVT_PARAM1", 0), bundle.getInt("EVT_PARAM2", 0));
break;
}
}
@Override
public void onNetStatus(TXVodPlayer txVodPlayer, Bundle bundle) {
}
public void release() {
if (mPlayer != null) {
/* if (mPlayer != null) {
mPlayer.stopPlay(false);
mPlayer.setPlayListener(null);
}
mPlayer = null;
mPlayer = null;*/
mActionListener = null;
}
@ -279,9 +235,9 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
*/
public void pausePlay() {
mPaused = true;
if (!mClickPaused && mPlayer != null) {
/* if (!mClickPaused && mPlayer != null) {
mPlayer.pause();
}
}*/
}
/**
@ -289,9 +245,9 @@ public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListe
*/
public void resumePlay() {
if (mPaused) {
if (!mClickPaused && mPlayer != null) {
/* if (!mClickPaused && mPlayer != null) {
mPlayer.resume();
}
}*/
}
mPaused = false;
}

View File

@ -49,11 +49,11 @@
android:layout_height="match_parent"
android:layout_marginTop="72dp">
<com.tencent.rtmp.ui.TXCloudVideoView
<!-- <com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
android:layout_centerInParent="true" />-->
<View
android:id="@+id/video_cover"

View File

@ -21,7 +21,7 @@
app:cardCornerRadius="4dp"
app:cardElevation="0dp">
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -17,9 +17,6 @@ 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.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
@ -54,9 +51,9 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
private int mLiveTypeVal;
private FloatCallbacks.Builder builder;
private String TAG = "LiveFloatView";
private TXLivePlayer mPlayer;
// private TXLivePlayer mPlayer;
private FrameLayout videoFrameLayout;
private TXCloudVideoView videoView;
// private TXCloudVideoView videoView;
private SWAuManager swAuManager;
public static LiveFloatView getInstance() {
@ -96,7 +93,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
//进入主播房间
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,mLiveBean.getUid(), SWAuManager.getChannelName(mLiveBean.getUid()));
}else{
videoView = magnetView.findViewById(R.id.video_view);
/*videoView = magnetView.findViewById(R.id.video_view);
mPlayer = new TXLivePlayer(mContext);
mPlayer.setPlayerView(videoView);
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
@ -122,7 +119,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
public void onNetStatus(Bundle bundle) {
}
});
});*/
}
ViewClicksAntiShake.clicksAntiShake(magnetView.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@ -131,7 +128,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
if(mLiveSDK){
SWAuManager.get().exitChannelAll();
}else{
mPlayer.stopPlay(true);
// mPlayer.stopPlay(true);
}
APPEasyFloat.getInstance().dismiss(mContext);
if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) {
@ -150,11 +147,11 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
new Handler().post(liveCheck);
});
}else{
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
/*ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
mPlayer.stopPlay(true);
APPEasyFloat.getInstance().dismiss(mContext);
new Handler().post(liveCheck);
});
});*/
}
}
@ -169,8 +166,8 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
if(mLiveSDK){
SWAuManager.get().exitChannelAll();
}else{
if (mPlayer != null)
mPlayer.stopPlay(true);
/* if (mPlayer != null)
mPlayer.stopPlay(true);*/
}
}
@ -211,15 +208,15 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
callback.invoke(aBoolean);
}
builder.dismiss(() -> {
if (mPlayer != null && mPlayer.isPlaying()) {
/*if (mPlayer != null && mPlayer.isPlaying()) {
mPlayer.stopPlay(true);
}
}*/
return null;
});
builder.hide(view12 -> {
if (mPlayer != null && mPlayer.isPlaying()) {
/*if (mPlayer != null && mPlayer.isPlaying()) {
mPlayer.pause();
}
}*/
return null;
});
@ -256,7 +253,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
//进入主播房间
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, mLiveBean.getUid(),SWAuManager.getChannelName(mLiveBean.getUid()));
}else{
TXCloudVideoView videoView = view.findViewById(R.id.video_view);
/* TXCloudVideoView videoView = view.findViewById(R.id.video_view);
mPlayer = new TXLivePlayer(mContext);
mPlayer.setPlayerView(videoView);
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
@ -283,7 +280,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
public void onNetStatus(Bundle bundle) {
}
});
});*/
}
ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@ -292,7 +289,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
if(mLiveSDK){
SWAuManager.get().exitChannelAll();
}else{
mPlayer.stopPlay(true);
// mPlayer.stopPlay(true);
}
EasyFloat.dismiss("LiveFloatView", true);
@ -309,7 +306,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
if(mLiveSDK){
SWAuManager.get().exitChannelAll();
}else{
mPlayer.stopPlay(true);
// mPlayer.stopPlay(true);
}
new Handler().post(liveCheck);

View File

@ -1,9 +1,5 @@
package com.yunbao.live.activity;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
import static com.yunbao.live.views.LivePushTxViewHolder.mTRTCCloud;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
@ -21,10 +17,6 @@ import com.lzy.okgo.model.Progress;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.opensource.svgaplayer.SVGAImageView;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.tencent.trtc.TRTCCloudDef;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@ -292,7 +284,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
break;
case Constants.LIVE_FUNC_MIRROR://鏡像
TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
/* TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
if (mrr == 0) {
mrr = 1;
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_ENABLE;
@ -300,7 +292,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
mrr = 0;
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_DISABLE;
}
mTRTCCloud.setLocalRenderParams(t);
mTRTCCloud.setLocalRenderParams(t);*/
break;
default:
break;
@ -569,7 +561,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
mSocketClient.disConnect();
}
if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) {
/* if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) {
LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom();
LiveLinkMicPkPresenter.mTRTCCloud1.stopLocalPreview();
}
@ -579,7 +571,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
LivePushTxViewHolder.mTRTCCloud.stopLocalPreview();
}
*/
if (mLivePushViewHolder != null) {
mLivePushViewHolder.release();
}
@ -638,9 +630,9 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
mLiveEndViewHolder.subscribeActivityLifeCycle();
mLiveEndViewHolder.addToParent();
mLiveEndViewHolder.showData(mLiveBean, mStream);
if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) {
LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom();
}
/* if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) {
// LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom();
}*/
if (mLivePushViewHolder != null) {
mLivePushViewHolder.release();
@ -863,7 +855,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar());
msgs.create();
V2TIMManager.getInstance().sendC2CTextMessage(msgs.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
/* V2TIMManager.getInstance().sendC2CTextMessage(msgs.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
@ -880,7 +872,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
ToastUtil.show("发送失败,请重试");
}
});
});*/
} else {
ToastUtil.show(getString(R.string.pking_over));
}
@ -916,7 +908,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("uid", CommonAppConfig.getInstance().getUid());
msgs.create();
V2TIMManager.getInstance().sendC2CTextMessage(msgs.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
/* V2TIMManager.getInstance().sendC2CTextMessage(msgs.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
@ -933,7 +925,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
ToastUtil.show("发送失败,请重试");
}
});
});*/
} else {
ToastUtil.show(mContext.getString(R.string.pking_over));
}

View File

@ -1,290 +0,0 @@
package com.yunbao.live.activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.NewLevelModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.live.R;
import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.dialog.LiveShareDialogFragment;
import com.yunbao.live.presenter.UserHomeSharePresenter;
import com.yunbao.live.views.LiveRecordPlayViewHolder;
import java.util.List;
/**
* Created by cxf on 2018/10/29.
*/
public class LiveRecordPlayActivity extends AbsActivity implements
LiveRecordPlayViewHolder.ActionListener, View.OnClickListener, LiveShareDialogFragment.ActionListener {
private LiveRecordPlayViewHolder mLiveRecordPlayViewHolder;
private ImageView mAvatar;
private ImageView mLevelAnchor;
private TextView mName;
private TextView mID;
private View mBtnFollow;
private SeekBar mSeekBar;
private long mDuration;
private TextView mCurTimeTextView;
private TextView mDurationTextView;
private ImageView mBtnPlay;
private UserBean mUserBean;
private UserHomeSharePresenter mUserHomeSharePresenter;
private boolean mPausePlay;
public static void forward(Context context, String url, UserBean userBean) {
if (TextUtils.isEmpty(url) || userBean == null) {
return;
}
Intent intent = new Intent(context, LiveRecordPlayActivity.class);
intent.putExtra(Constants.URL, url);
intent.putExtra(Constants.USER_BEAN, userBean);
context.startActivity(intent);
}
@Override
protected int getLayoutId() {
return R.layout.activity_live_record_play;
}
@Override
protected boolean isStatusBarWhite() {
return true;
}
@Override
protected void main() {
Intent intent = getIntent();
mUserBean = intent.getParcelableExtra(Constants.USER_BEAN);
if (mUserBean == null) {
return;
}
String url = intent.getStringExtra(Constants.URL);
if (TextUtils.isEmpty(url)) {
return;
}
mAvatar = (ImageView) findViewById(R.id.avatar);
mLevelAnchor = (ImageView) findViewById(R.id.level_anchor);
mName = (TextView) findViewById(R.id.name);
mID = (TextView) findViewById(R.id.id_val);
mBtnFollow = findViewById(R.id.btn_follow);
ImgLoader.displayAvatar(mContext, mUserBean.getAvatar(), mAvatar);
List<NewLevelModel> models = new NewLevelManager(mContext).getNewAnchorLevelModels();
String imgUrl = "";
for (NewLevelModel newLevelModel : models) {
if (newLevelModel.getLeveMin() <= mUserBean.getLevelAnchor() && mUserBean.getLevelAnchor() <= newLevelModel.getLeveMax()) {
imgUrl = newLevelModel.getIcon();
}
ImgLoader.display(mContext, imgUrl, mLevelAnchor);
}
mName.setText(mUserBean.getUserNiceName());
mID.setText(mUserBean.getLiangNameTip());
if (mUserBean instanceof SearchUserBean) {
SearchUserBean searchUserBean = (SearchUserBean) mUserBean;
int attention = searchUserBean.getAttention();
if (attention == 0) {
if (mBtnFollow.getVisibility() != View.VISIBLE) {
mBtnFollow.setVisibility(View.VISIBLE);
}
}
mBtnFollow.setOnClickListener(this);
}
mUserHomeSharePresenter = new UserHomeSharePresenter(mContext);
mUserHomeSharePresenter.setToUid(mUserBean.getId())
.setToName(mUserBean.getUserNiceName())
.setAvatarThumb(mUserBean.getAvatarThumb())
.setFansNum(String.valueOf(mUserBean.getFans()));
findViewById(R.id.btn_back).setOnClickListener(this);
findViewById(R.id.btn_share).setOnClickListener(this);
mBtnPlay = findViewById(R.id.btn_play);
mBtnPlay.setOnClickListener(this);
mSeekBar = (SeekBar) findViewById(R.id.seek_bar);
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (mLiveRecordPlayViewHolder != null) {
mLiveRecordPlayViewHolder.clickResume();
int progress = seekBar.getProgress();
mLiveRecordPlayViewHolder.seekTo(mDuration * progress / 100000f);
}
}
});
mCurTimeTextView = findViewById(R.id.cur_time);
mDurationTextView = findViewById(R.id.duration);
ViewGroup container = (ViewGroup) findViewById(R.id.container);
mLiveRecordPlayViewHolder = new LiveRecordPlayViewHolder(mContext, container);
mLiveRecordPlayViewHolder.setActionListener(this);
mLiveRecordPlayViewHolder.subscribeActivityLifeCycle();
mLiveRecordPlayViewHolder.addToParent();
mLiveRecordPlayViewHolder.play(url);
}
@Override
public void onBackPressed() {
super.onBackPressed();
if (mLiveRecordPlayViewHolder != null) {
mLiveRecordPlayViewHolder.release();
}
}
@Override
protected void onDestroy() {
if (mLiveRecordPlayViewHolder != null) {
mLiveRecordPlayViewHolder.release();
}
if (mUserHomeSharePresenter != null) {
mUserHomeSharePresenter.release();
}
super.onDestroy();
}
@Override
public void onProgress(int progress) {
if (mSeekBar != null) {
mSeekBar.setProgress(progress);
}
}
@Override
public void onDuration(long duration) {
mDuration = duration;
if (mDurationTextView != null) {
mDurationTextView.setText(StringUtil.getDurationText(duration));
}
}
@Override
public void onCurTime(long curTime) {
if (mCurTimeTextView != null) {
mCurTimeTextView.setText(StringUtil.getDurationText(curTime));
}
}
@Override
public void onClickPause() {
if (mBtnPlay != null) {
mBtnPlay.setImageResource(R.mipmap.icon_live_record_play);
}
}
@Override
public void onClickResume() {
if (mBtnPlay != null) {
mBtnPlay.setImageResource(R.mipmap.icon_live_record_pause);
}
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.btn_back) {
onBackPressed();
} else if (i == R.id.btn_share) {
share();
} else if (i == R.id.btn_play) {
togglePlay();
} else if (i == R.id.btn_follow) {
follow();
}
}
/**
* 切换播放暂停
*/
private void togglePlay() {
if (mLiveRecordPlayViewHolder != null) {
if (mPausePlay) {
mLiveRecordPlayViewHolder.clickResume();
} else {
mLiveRecordPlayViewHolder.clickPause();
}
mPausePlay = !mPausePlay;
}
}
/**
* 关注主播
*/
private void follow() {
if (mUserBean == null) {
return;
}
CommonHttpUtil.setAttention(mUserBean.getId(), new CommonCallback<Integer>() {
@Override
public void callback(Integer isAttention) {
if (isAttention == 1) {
if (mBtnFollow.getVisibility() == View.VISIBLE) {
mBtnFollow.setVisibility(View.GONE);
}
}
}
});
}
/**
* 分享
*/
private void share() {
LiveShareDialogFragment fragment = new LiveShareDialogFragment();
fragment.setActionListener(this);
fragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveShareDialogFragment");
}
@Override
public void onItemClick(String type) {
if (Constants.LINK.equals(type)) {
copyLink();
} else {
shareHomePage(type);
}
}
/**
* 复制页面链接
*/
private void copyLink() {
if (mUserHomeSharePresenter != null) {
mUserHomeSharePresenter.copyLink();
}
}
/**
* 分享页面链接
*/
private void shareHomePage(String type) {
if (mUserHomeSharePresenter != null) {
mUserHomeSharePresenter.shareHomePage(type);
}
}
}

View File

@ -1,7 +1,5 @@
package com.yunbao.live.activity;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_dr_pk_nub;
@ -40,7 +38,6 @@ import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.interfaces.XPopupCallback;
import com.lzf.easyfloat.enums.ShowPattern;
import com.opensource.svgaplayer.SVGAImageView;
import com.tencent.trtc.TRTCCloudDef;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@ -534,13 +531,13 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
break;
case Constants.LIVE_FUNC_MIRROR://鏡像
TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
// TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
if (mrr == 0) {
mrr = 1;
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_ENABLE;
// t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_ENABLE;
} else if (mrr == 1) {
mrr = 0;
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_DISABLE;
// t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_DISABLE;
}
break;
case Constants.LIVE_FUNC_RANDOM_PK:

View File

@ -14,12 +14,6 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.tencent.liteav.TXLiteAVCode;
import com.tencent.liteav.device.TXDeviceManager;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.tencent.trtc.TRTCCloud;
import com.tencent.trtc.TRTCCloudDef;
import com.tencent.trtc.TRTCCloudListener;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@ -44,18 +38,16 @@ import org.json.JSONObject;
import java.lang.ref.WeakReference;
import static com.tencent.trtc.TRTCCloudDef.TRTC_APP_SCENE_LIVE;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG;
public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
private TXCloudVideoView mTxcvvAnchorPreviewView;
// private TXCloudVideoView mTxcvvAnchorPreviewView;
private ImageView mButtonSwitchCamera;
private TRTCCloud mTRTCCloud;
private TXDeviceManager mTXDeviceManager;
private TRTCCloudDef.TRTCParams mTRTCParams;
// private TRTCCloud mTRTCCloud;
// private TXDeviceManager mTXDeviceManager;
// private TRTCCloudDef.TRTCParams mTRTCParams;
private boolean mIsFrontCamera = true;
private String mRoomId = "1256732";
private String mUserId = "95895736";
@ -80,13 +72,13 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
setContentView(R.layout.activity_live_trtcanchor);
mTRTCCloud = TRTCCloud.sharedInstance(LiveTRTCAnchorActivity.this);
// mTRTCCloud = TRTCCloud.sharedInstance(LiveTRTCAnchorActivity.this);
mMainHandler = new Handler(Looper.getMainLooper());
mTXDeviceManager = mTRTCCloud.getDeviceManager();
mTRTCCloud.setListener(new TRTCCloudImplListener(LiveTRTCAnchorActivity.this));
// mTXDeviceManager = mTRTCCloud.getDeviceManager();
// mTRTCCloud.setListener(new TRTCCloudImplListener(LiveTRTCAnchorActivity.this));
mTRTCCloud.setLocalVideoProcessListener(TRTCCloudDef.TRTC_VIDEO_PIXEL_FORMAT_Texture_2D,
/*mTRTCCloud.setLocalVideoProcessListener(TRTCCloudDef.TRTC_VIDEO_PIXEL_FORMAT_Texture_2D,
TRTCCloudDef.TRTC_VIDEO_BUFFER_TYPE_TEXTURE,
new TRTCCloudListener.TRTCVideoFrameListener() {
@ -114,7 +106,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
}
});
*/
if (checkPermission()) {
initView();
enterRoom();
@ -131,7 +123,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
protected void initView() {
mButtonSwitchCamera = findViewById(R.id.live_btn_switch_camera);
mTxcvvAnchorPreviewView = findViewById(R.id.live_cloud_view_main);
// mTxcvvAnchorPreviewView = findViewById(R.id.live_cloud_view_main);
btn_beauty = findViewById(R.id.btn_beauty);
ready_view = (View) findViewById(R.id.ready_view);
live_class = (TextView) findViewById(R.id.live_class);
@ -169,7 +161,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
}
});
mTRTCCloud.setListener(new TRTCCloudImplListener(LiveTRTCAnchorActivity.this));
// mTRTCCloud.setListener(new TRTCCloudImplListener(LiveTRTCAnchorActivity.this));
mButtonSwitchCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -181,7 +173,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
public void enterRoom() {
mTRTCParams = new TRTCCloudDef.TRTCParams();
/* mTRTCParams = new TRTCCloudDef.TRTCParams();
mTRTCParams.sdkAppId = GenerateTestUserSig.SDKAPPID;
mTRTCParams.userId = mUserId;
mTRTCParams.roomId = Integer.parseInt(mRoomId);
@ -190,7 +182,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
mTRTCCloud.startLocalPreview(mIsFrontCamera, mTxcvvAnchorPreviewView);
mTRTCCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_DEFAULT);
mTRTCCloud.enterRoom(mTRTCParams, TRTC_APP_SCENE_LIVE);
mTRTCCloud.enterRoom(mTRTCParams, TRTC_APP_SCENE_LIVE);*/
}
@ -223,7 +215,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
try {
JSONObject data = new JSONObject(info[0]);
mTRTCCloud.startPublishing(data.getString("stream"), TRTC_VIDEO_STREAM_TYPE_BIG);
// mTRTCCloud.startPublishing(data.getString("stream"), TRTC_VIDEO_STREAM_TYPE_BIG);
ready_view.setVisibility(View.VISIBLE);
} catch (JSONException e) {
@ -244,11 +236,11 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
} else {
mIsFrontCamera = true;
}
mTXDeviceManager.switchCamera(mIsFrontCamera);
// mTXDeviceManager.switchCamera(mIsFrontCamera);
}
protected class TRTCCloudImplListener extends TRTCCloudListener {
/*protected class TRTCCloudImplListener extends TRTCCloudListener {
private WeakReference<LiveTRTCAnchorActivity> mContext;
@ -284,18 +276,18 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
}
}
}
}*/
protected void exitRoom() {
if (mTRTCCloud != null) {
/* if (mTRTCCloud != null) {
mTRTCCloud.stopLocalAudio();
mTRTCCloud.stopLocalPreview();
mTRTCCloud.exitRoom();
mTRTCCloud.setListener(null);
}
mTRTCCloud = null;
TRTCCloud.destroySharedInstance();
TRTCCloud.destroySharedInstance();*/
}
@Override

View File

@ -1,9 +1,10 @@
package com.example.txvidotest
import android.content.Context
import android.widget.Toast
import com.cosmos.baseutil.file.FileUtil
import com.cosmos.baseutil.thread.ThreadUtils
import com.tencent.liteav.basic.util.TXCCommonUtil.getAppContext
import com.cosmos.baseutil.toast.Toaster
import java.io.File
object FilterUtils {
@ -44,7 +45,8 @@ object FilterUtils {
}
fun getBeautyDirectory(): File? {
return File(getAppContext().filesDir?.absolutePath, "/beauty")
Toaster.show("请联系开发者")
return null
}
fun getFilterHomeDir(): File {

View File

@ -17,12 +17,6 @@ import android.widget.PopupWindow;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.tencent.trtc.TRTCCloud;
import com.tencent.trtc.TRTCCloudDef;
import com.tencent.trtc.TRTCCloudListener;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@ -54,10 +48,8 @@ import java.util.ArrayList;
import java.util.List;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
import static com.tencent.trtc.TRTCCloudDef.TRTC_APP_SCENE_LIVE;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.live.activity.LiveAnchorActivity.isDRPK;
import static com.yunbao.live.views.AbsLivePushViewHolder.mPreView;
import static com.yunbao.live.views.LivePushTxViewHolder.dr_pk_view;
import io.rong.imlib.IRongCallback;
@ -107,13 +99,13 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
private int mPkSendWaitCount;//发送pk请求后的等待时间
private String mSelfStream;
private int mPkTimeFromServer;
public static TRTCCloud mTRTCCloud1;
public static TRTCCloudDef.TRTCParams mTRTCParams1;
public static TRTCCloud mTRTCCloud2;
public static TRTCCloud mTRTCCloud3;
public static TRTCCloud mTRTCCloud4;
public static TRTCCloud mTRTCCloud5;
// public static TRTCCloud mTRTCCloud1;
// public static TRTCCloudDef.TRTCParams mTRTCParams1;
//
// public static TRTCCloud mTRTCCloud2;
// public static TRTCCloud mTRTCCloud3;
// public static TRTCCloud mTRTCCloud4;
// public static TRTCCloud mTRTCCloud5;
public LiveLinkMicPkPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, View root) {
mContext = context;
@ -239,13 +231,13 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
s1 = "00:00";
i = 0;
}
if (LiveLinkMicPkPresenter.mTRTCCloud1 != null && LivePushTxViewHolder.mTRTCCloud != null) {
/* if (LiveLinkMicPkPresenter.mTRTCCloud1 != null && LivePushTxViewHolder.mTRTCCloud != null) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mContext.getResources().getDimensionPixelOffset(R.dimen.live_view));
params.weight = 1;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
LivePushTxViewHolder.mPreView.setLayoutParams(params);
LivePushTxViewHolder.mPreView1.setLayoutParams(params);
}
}*/
Log.i("tts", s1);
mLiveLinkMicPkViewHolder.setTime(s + " " + s1);
@ -370,7 +362,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
user.add(u);
Log.i("1111", "12222222a" + user.size());
mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
/* mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
mTRTCParams1 = new TRTCCloudDef.TRTCParams();
mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID;
mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk";
@ -393,7 +385,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
mTRTCCloud1.startRemoteView(u.getId(), LivePushTxViewHolder.dr4_preview);
mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
}
}*/
}
//接受PK回调
@ -459,7 +451,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
*/
public void onLinkMicToPk(String u, String pkhead, String pkname) {
Log.e("eve", u + "");
mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
/* mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
mTRTCParams1 = new TRTCCloudDef.TRTCParams();
mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID;
mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk";
@ -468,7 +460,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mTRTCParams1.role = TRTCCloudDef.TRTCRoleAnchor;
mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
mTRTCCloud1.startRemoteView(u, LivePushTxViewHolder.mPreView1);
mTRTCCloud1.setListener(new TRTCCloudImplListener(mContext));
mTRTCCloud1.setListener(new TRTCCloudImplListener(mContext));*/
LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mContext.getResources().getDimensionPixelOffset(R.dimen.live_view));
@ -488,7 +480,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
.param("pkname", pkname);
msg1.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg1.mResult.toString(), "g" + CommonAppConfig.getInstance().getUid(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
/* V2TIMManager.getInstance().sendGroupTextMessage(msg1.mResult.toString(), "g" + CommonAppConfig.getInstance().getUid(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
@ -504,13 +496,13 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败" + desc);
}
});
});*/
}
List<String> muser = new ArrayList<>();
protected class TRTCCloudImplListener extends TRTCCloudListener {
/*protected class TRTCCloudImplListener extends TRTCCloudListener {
private WeakReference<Context> mContext;
@ -688,7 +680,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
super.onError(errCode, errMsg, extraInfo);
Log.i("errMsg", errCode + "errMsg" + errMsg);
}
}
}*/
/**
* 显示申请PK的弹窗
@ -803,7 +795,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
.param("uid", u.getId())
.param("pkuid",CommonAppConfig.getInstance().getUid());
msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), list.get(i).getId() + "", new V2TIMSendCallback<V2TIMMessage>() {
/* V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), list.get(i).getId() + "", new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
@ -819,7 +811,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
ToastUtil.show("发送失败");
}
});
});*/
}

View File

@ -34,7 +34,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.tencent.trtc.TRTCCloud;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.AnchorInfoEvent;
@ -124,7 +123,6 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
private int mPkSendWaitCount;//发送pk请求后的等待时间
private String mSelfStream;
private int mPkTimeFromServer;
public static TRTCCloud mTRTCCloud1;
private View detailsView1, detailsView2, detailsView3, detailsView4;
private LinearLayout detailsLinearLayout1, detailsLinearLayout2, detailsLinearLayout3, detailsLinearLayout4;
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;

View File

@ -1,671 +0,0 @@
package com.yunbao.live.socket;
import android.util.Log;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.live.R;
/**
* Created by cxf on 2018/10/9.
* 直播间发言
*/
public class SocketChatUtil {
//关闭直播
public static void closeLive(final String mLiveUid, SocketClient client) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_END)
.param("action", 18)
.param("msgtype", 1)
.param("equipment", "app")
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("roomnum", u.getId())
.param("ct", "直播关闭");
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
V2TIMManager.getInstance().dismissGroup("g" + mLiveUid, new V2TIMCallback() {
@Override
public void onSuccess() {
Log.i("tx", "解散成功");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "解散失败" + desc);
}
});
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败1" + desc);
}
});
}
/**
* 发言
*/
public static void sendChatMessage(String mLiveUid, String content, boolean isAnchor, int userType, int guardType) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg =
new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_MSG)
.param("action", 0)
.param("msgtype", 2)
.param("usertype", userType)
.param("isAnchor", isAnchor ? 1 : 0)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("bubble", u.getDress().getBubble())
.param("medal_honor", u.getMedal_no_display_src())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("uid", u.getId())
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("guard_type", guardType)
.param("medal_name", u.getMedalName())
.param("medal_level", u.getMedalLevel())
.param("good_num", u.getGoodnum())
.param("ct", content);
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败2" + desc);
}
});
}
/**
* 点亮
*/
public static void sendLightMessage(final String mLiveUid, int heart, int guardType) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_MSG)
.param("action", 0)
.param("msgtype", 2)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("medal_honor", u.getMedal_no_display_src())
.param("heart", heart)
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("guard_type", guardType)
.param("medal_name", u.getMedalName())
.param("medal_level", u.getMedalLevel())
.param("good_num", u.getGoodnum())
.param("ct", CommonAppContext.sInstance.getBaseContext().getString(R.string.live_lighted));
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
LiveHttpUtil.sendZAN(mLiveUid, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i("tag", "禮物im");
}
});
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败3" + desc);
}
});
}
/**
* 发送弹幕消息
*/
public static void sendDanmuMessage(String mLiveUid, String danmuToken) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_BARRAGE)
.param("action", 7)
.param("msgtype", 1)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("uhead", u.getAvatar())
.param("ct", danmuToken);
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败4" + desc);
}
});
}
/**
* 发送礼物消息
*/
public static void sendGiftMessage(int giftType, String giftToken, String liveUid, int guard_type, String by) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_GIFT)
.param("action", 0)
.param("msgtype", 1)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("uhead", u.getAvatar())
.param("evensend", giftType)
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("ct", giftToken)
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("medal_name", u.getMedalName())
.param("medal_level", u.getMedalLevel())
.param("guard_type", guard_type + "")
.param("medal_honor", u.getMedal_no_display_src())
.param("good_num", u.getGoodnum())
.param("roomnum", liveUid);
msg.create();
LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i("tag", "禮物im");
}
});
}
/**
* 发送礼物消息 增加主播名字
*/
public static void sendGiftMessage(int giftType, String giftToken,
String liveUid, String ancherName, int guard_type, String by) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_GIFT)
.param("action", 0)
.param("msgtype", 1)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("uhead", u.getAvatar())
.param("evensend", giftType)
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("ct", giftToken)
.param("ancherName", ancherName)
.param("medal_name", u.getMedalName())
.param("medal_level", u.getMedalLevel())
.param("guard_type", guard_type + "")
.param("medal_honor", u.getMedal_no_display_src())
.param("good_num", u.getGoodnum())
.param("roomnum", liveUid);
msg.create();
LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i("tag", "禮物im");
}
});
}
/**
* 主播或管理员 踢人
*/
public static void sendKickMessage(String mLiveUid, String toUid, String toName) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_KICK)
.param("action", 2)
.param("msgtype", 4)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("touid", toUid)
.param("toname", toName)
.param("ct", toName + CommonAppContext.sInstance.getBaseContext().getString(R.string.live_kicked));
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败5" + desc);
}
});
}
/**
* 主播或管理员 禁言
*/
public static void sendShutUpMessage(String mLiveUid, String toUid, String toName, int type) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SHUT_UP)
.param("action", 1)
.param("msgtype", 4)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("touid", toUid)
.param("toname", toName)
.param("ct", toName + (type == 0 ? "被永久禁言(Forbidden forever)" : "被本場禁言(Forbidden by this scene)"));
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败6" + desc);
}
});
}
/**
* 设置或取消管理员消息
*/
public static void sendSetAdminMessage(String mLiveUid, int action, String toUid, String toName) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
String s = action == 1 ? "被設為管理員(Set as Administrator)": "被取消管理員(Cancelled administrator)";
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SET_ADMIN)
.param("action", action)
.param("msgtype", 1)
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("touid", toUid)
.param("toname", toName)
.param("ct", toName + " " + s);
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败7" + desc);
}
});
}
/**
* 超管关闭直播间
*/
public static void superCloseRoom(String mLiveUid) {
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_STOP_LIVE)
.param("action", 19)
.param("msgtype", 1)
.param("ct", "");
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败7" + desc);
}
});
}
/**
* 发系统消息
*/
public static void sendSystemMessage(String mLiveUid, String content) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SYSTEM)
.param("action", 13)
.param("msgtype", 4)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("ct", content);
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功" + msg.mResult.toString());
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败9" + desc);
}
});
}
/**
* 获取僵尸粉
*/
public static void getFakeFans(String mLiveUid) {
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_FAKE_FANS)
.param("action", "")
.param("msgtype", "");
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败10" + desc);
}
});
}
/**
* 更新主播映票数
*/
public static void sendUpdateVotesMessage(String mLiveUid, int votes, int first) {
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_UPDATE_VOTES)
.param("action", 1)
.param("msgtype", 26)
.param("votes", votes)
.param("uid", CommonAppConfig.getInstance().getUid())
.param("isfirst", first)
.param("ct", "");
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败" + desc);
}
});
}
/**
* 更新主播映票数
*/
public static void sendUpdateVotesMessage(String mLiveUid, int votes) {
sendUpdateVotesMessage(mLiveUid, votes, 0);
}
/**
* 发送购买守护成功消息
*/
public static void sendBuyGuardMessage(String mLiveUid, String votes, int guardNum, int guardType) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_BUY_GUARD)
.param("action", 0)
.param("msgtype", 0)
.param("uid", u.getId())
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("uname", u.getUserNiceName())
.param("uhead", u.getAvatar())
.param("votestotal", votes)
.param("guard_nums", guardNum)
.param("guard_type", guardType);
msg.create();
}
public static void sendBuyGuardMessage2(String mLiveUid, String votes, int guardNum,
int guardType, String ancherName, String liveId) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_BUY_GUARD)
.param("action", 0)
.param("msgtype", 0)
.param("uid", u.getId())
.param("uname", u.getUserNiceName())
.param("uhead", u.getAvatar())
.param("votestotal", votes)
.param("guard_nums", guardNum)
.param("ancherName", ancherName)
.param("liveuid", liveId)
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("guard_type", guardType);
msg.create();
}
/**
* 发送发红包成功消息
*/
public static void sendRedPackMessage(String mLiveUid) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_RED_PACK)
.param("action", 0)
.param("msgtype", 0)
.param("uid", u.getId())
.param("uname", u.getUserNiceName())
.param("ct", CommonAppContext.sInstance.getBaseContext().getString(R.string.red_pack_22)
);
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx", "发送中" + progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx", "发送成功");
SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", code + "发送失败" + desc);
}
});
}
}

View File

@ -11,8 +11,6 @@ import android.widget.LinearLayout;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@ -57,7 +55,7 @@ public class SocketClient {
public SocketClient(String mLiveUid, SocketMessageListener listener) {
mSocketHandler = new SocketHandler(listener);
mSocketHandler.setLiveUid(mLiveUid);
V2TIMManager.getInstance().joinGroup("g" + mLiveUid, "", new V2TIMCallback() {
/*V2TIMManager.getInstance().joinGroup("g" + mLiveUid, "", new V2TIMCallback() {
@Override
public void onSuccess() {
Log.i("tx", "加入成功");
@ -67,7 +65,7 @@ public class SocketClient {
public void onError(int code, String desc) {
Log.i("tx", desc + "加入" + "失败" + code);
}
});
});*/
}
public void disConnect() {
@ -785,7 +783,7 @@ public class SocketClient {
mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));
break;
case 5://PK时候断开连麦的回调
if (LivePushTxViewHolder.mTRTCCloud != null) {
/*if (LivePushTxViewHolder.mTRTCCloud != null) {
if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) {
LiveLinkMicPkPresenter.mTRTCCloud1.stopRemoteView(map.getString("uid"));
LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom();
@ -804,7 +802,7 @@ public class SocketClient {
}
});
Log.i("zzzv", "1");
}
}*/
mListener.onLinkMicPkClose(1);
break;
case 7://对方主播正在忙的回调

View File

@ -1,645 +0,0 @@
package com.yunbao.live.socket;
import android.util.Log;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
/**
* Created by cxf on 2018/10/31.
*/
public class SocketGameUtil {
/**
* 智勇三张 开启游戏窗口
*/
public static void zjhShowGameWindow() {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_GAME_ZJH)
// .param("action", GameConsts.GAME_ACTION_OPEN_WINDOW)
.param("msgtype", 15)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("ct", "");
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(),"g"+u.getId(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx","发送中"+progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx","发送成功");
}
@Override
public void onError(int code, String desc) {
Log.i("tx",code+"发送失败"+desc);
}
});
}
/**
* 智勇三张 主播创建游戏
*/
public static void zjhAnchorCreateGame(String gameId) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_GAME_ZJH)
// .param("action", GameConsts.GAME_ACTION_CREATE)
.param("msgtype", 15)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("gameid", gameId)
.param("ct", "");
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(),"g"+u.getId(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx","发送中"+progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx","发送成功");
}
@Override
public void onError(int code, String desc) {
Log.i("tx",code+"发送失败"+desc);
}
});
}
/**
* 智勇三张 主播关闭游戏
*/
public static void zjhAnchorCloseGame() {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_GAME_ZJH)
// .param("action", GameConsts.GAME_ACTION_CLOSE)
.param("msgtype", 15)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("ct", "");
msg.create();
V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(),"g"+u.getId(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
Log.i("tx","发送中"+progress);
}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {
Log.i("tx","发送成功");
}
@Override
public void onError(int code, String desc) {
Log.i("tx",code+"发送失败"+desc);
}
});
}
/**
* 智勇三张 主播通知所有人下注
* 此时服务器收到该socket后自动计时30秒后自动发送显示游戏结果的socket
*/
public static void zjhAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_ZJH)
// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
// .param("msgtype", 15)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("liveuid", liveUid)
// .param("gameid", gameId)
// .param("token", token)
// .param("time", time)
// .param("ct", "")
// );
// ssss
}
/**
* 智勇三张 观众把自己的下注信息广播给所有人
*/
public static void zjhAudienceBetGame(SocketClient client, int coin, int index) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_ZJH)
// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
// .param("msgtype", 15)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("money", coin)
// .param("type", index)
// .param("ct", "")
// );
}
/**
* 海盗船长 开启游戏窗口
*/
public static void hdShowGameWindow(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_HD)
// .param("action", 1)
// .param("msgtype", 18)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 海盗船长 主播创建游戏
*/
public static void hdAnchorCreateGame(SocketClient client, String gameId) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_HD)
// .param("action", GameConsts.GAME_ACTION_CREATE)
// .param("msgtype", 18)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("gameid", gameId)
// .param("ct", "")
// );
}
/**
* 海盗船长 主播关闭游戏
*/
public static void hdAnchorCloseGame(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_HD)
// .param("action", GameConsts.GAME_ACTION_CLOSE)
// .param("msgtype", 18)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 海盗船长 主播通知所有人下注
* 此时服务器收到该socket后自动计时30秒后自动发送显示游戏结果的socket
*/
public static void hdAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_HD)
// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
// .param("msgtype", 18)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("liveuid", liveUid)
// .param("gameid", gameId)
// .param("token", token)
// .param("time", time)
// .param("ct", "")
// );
}
/**
* 海盗船长 观众把自己的下注信息广播给所有人
*/
public static void hdAudienceBetGame(SocketClient client, int coin, int index) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_HD)
// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
// .param("msgtype", 18)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("money", coin)
// .param("type", index)
// .param("ct", "")
// );
}
/**
* 幸运转盘 开启游戏窗口
*/
public static void zpShowGameWindow(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_ZP)
// .param("action", 1)
// .param("msgtype", 16)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 幸运转盘 主播关闭游戏
*/
public static void zpAnchorCloseGame(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_ZP)
// .param("action", GameConsts.GAME_ACTION_CLOSE)
// .param("msgtype", 16)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 幸运转盘 主播通知所有人下注
* 此时服务器收到该socket后自动计时30秒后自动发送显示游戏结果的socket
*/
public static void zpAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_ZP)
// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
// .param("msgtype", 16)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("liveuid", liveUid)
// .param("gameid", gameId)
// .param("token", token)
// .param("time", time)
// .param("ct", "")
// );
}
/**
* 幸运转盘 观众把自己的下注信息广播给所有人
*/
public static void zpAudienceBetGame(SocketClient client, int coin, int index) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_ZP)
// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
// .param("msgtype", 16)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("money", coin)
// .param("type", index)
// .param("ct", "")
// );
}
/**
* 开心牛仔 开启游戏窗口
*/
public static void nzShowGameWindow(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_NZ)
// .param("action", 1)
// .param("msgtype", 17)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 开心牛仔 主播创建游戏
* 本局的庄家信息 服务器用"bankerlist" 这个字段表示 其实是一个对象是一个人的信息
*/
public static void nzAnchorCreateGame(SocketClient client, String gameId, String bankerInfo) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_NZ)
// .param("action", GameConsts.GAME_ACTION_CREATE)
// .param("msgtype", 17)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("gameid", gameId)
// .param("ct", "")
// .paramJsonObject("bankerlist", bankerInfo)
// );
}
/**
* 开心牛仔 主播关闭游戏
*/
public static void nzAnchorCloseGame(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_NZ)
// .param("action", GameConsts.GAME_ACTION_CLOSE)
// .param("msgtype", 17)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 开心牛仔 主播通知所有人下注
* 此时服务器收到该socket后自动计时30秒后自动发送显示游戏结果的socket
*/
public static void nzAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_NZ)
// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
// .param("msgtype", 17)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("liveuid", liveUid)
// .param("gameid", gameId)
// .param("token", token)
// .param("time", time)
// .param("ct", "")
// );
}
/**
* 开心牛仔 观众把自己的下注信息广播给所有人
*/
public static void nzAudienceBetGame(SocketClient client, int coin, int index) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_NZ)
// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
// .param("msgtype", 17)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("money", coin)
// .param("type", index)
// .param("ct", "")
// );
}
/**
* 二八贝 开启游戏窗口
*/
public static void ebbShowGameWindow(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_EBB)
// .param("action", 1)
// .param("msgtype", 15)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 二八贝 主播创建游戏
*/
public static void ebbAnchorCreateGame(SocketClient client, String gameId) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_EBB)
// .param("action", GameConsts.GAME_ACTION_CREATE)
// .param("msgtype", 19)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("gameid", gameId)
// .param("ct", "")
// );
}
/**
* 二八贝 主播关闭游戏
*/
public static void ebbAnchorCloseGame(SocketClient client) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_EBB)
// .param("action", GameConsts.GAME_ACTION_CLOSE)
// .param("msgtype", 19)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("ct", "")
// );
}
/**
* 二八贝 主播通知所有人下注
* 此时服务器收到该socket后自动计时30秒后自动发送显示游戏结果的socket
*/
public static void ebbAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_EBB)
// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
// .param("msgtype", 19)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("liveuid", liveUid)
// .param("gameid", gameId)
// .param("token", token)
// .param("time", time)
// .param("ct", "")
// );
}
/**
* 二八贝 观众把自己的下注信息广播给所有人
*/
public static void ebbAudienceBetGame(SocketClient client, int coin, int index) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_GAME_EBB)
// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
// .param("msgtype", 19)
// .param("level", u.getLevel())
// .param("uname", u.getUserNiceName())
// .param("uid", u.getId())
// .param("money", coin)
// .param("type", index)
// .param("ct", "")
// );
}
}

View File

@ -2,9 +2,6 @@ package com.yunbao.live.socket;
import android.util.Log;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@ -69,7 +66,7 @@ public class SocketLinkMicPkUtil {
.param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("name", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
/* V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
@ -110,7 +107,7 @@ public class SocketLinkMicPkUtil {
ToastUtil.show("发送失败");
}
});
});*/
}
}
});
@ -152,7 +149,7 @@ public class SocketLinkMicPkUtil {
.param("ct", "");
msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
/* V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
@ -168,7 +165,7 @@ public class SocketLinkMicPkUtil {
ToastUtil.show("发送失败");
}
});
});*/
}

View File

@ -15,7 +15,7 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.utils.DpUtil;
@ -45,9 +45,9 @@ public abstract class AbsLivePushViewHolder extends AbsViewHolder implements ILi
protected ViewGroup mLeftContainer;
protected ViewGroup mRightContainer;
protected ViewGroup mPkContainer;
public static TXCloudVideoView mPreView,dr1_preview,dr2_preview,dr3_preview,dr4_preview;
public static StyledPlayerView mPreView,dr1_preview,dr2_preview,dr3_preview,dr4_preview;
public static ImageView leave;
public static TXCloudVideoView mPreView1;
public static StyledPlayerView mPreView1;
protected boolean mOpenCamera;//是否选择了相机

View File

@ -9,11 +9,6 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePlayConfig;
import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
@ -27,11 +22,11 @@ import cn.qqtheme.framework.util.ScreenUtils;
* 连麦播放小窗口 使用腾讯sdk
*/
public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder implements ITXLivePlayListener {
public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder {
private static final String TAG = "LiveLinkMicPlayTxViewHolder";
private TXCloudVideoView mVideoView;
private TXLivePlayer mPlayer;
// private TXCloudVideoView mVideoView;
// private TXLivePlayer mPlayer;
public LiveLinkMicPlayTxViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@ -45,7 +40,7 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void init() {
super.init();
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
/* mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
mPlayer = new TXLivePlayer(mContext);
mPlayer.setPlayListener(this);
mPlayer.setPlayerView(mVideoView);
@ -57,7 +52,7 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
playConfig.setAutoAdjustCacheTime(true);
playConfig.setMaxAutoAdjustCacheTime(5.0f);
playConfig.setMinAutoAdjustCacheTime(1.0f);
mPlayer.setConfig(playConfig);
mPlayer.setConfig(playConfig);*/
// TODO: 2019-11-10
@ -86,9 +81,9 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void play(final String url) {
if (TextUtils.isEmpty(url)) {
if (mPlayer != null) {
/* if (mPlayer != null) {
mPlayer.stopPlay(true);
}
}*/
mEndPlay = true;
return;
}
@ -97,9 +92,9 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void run() {
mEndPlay = false;
if (mPlayer != null) {
/*if (mPlayer != null) {
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_RTMP_ACC);
}
}*/
L.e(TAG, "play----url--->" + url);
}
}, 500);
@ -109,11 +104,11 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void release() {
mEndPlay = true;
if (mPlayer != null) {
/* if (mPlayer != null) {
mPlayer.stopPlay(false);
mPlayer.setPlayListener(null);
}
mPlayer = null;
mPlayer = null;*/
if (mBtnClose != null) {
mBtnClose.setOnClickListener(null);
}
@ -126,72 +121,18 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void resume() {
if (mPaused && mVideoView != null) {
/*if (mPaused && mVideoView != null) {
mPlayer.resume();
}
}*/
mPaused = false;
}
@Override
public void pause() {
if (mVideoView != null) {
/* if (mVideoView != null) {
mPlayer.pause();
}
}*/
mPaused = true;
}
@Override
public void onPlayEvent(int e, Bundle bundle) {
if (mEndPlay) {
return;
}
switch (e) {
case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://播放开始
if (mLoading != null && mLoading.getVisibility() == View.VISIBLE) {
mLoading.setVisibility(View.INVISIBLE);
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_LOADING:
if (mLoading != null && mLoading.getVisibility() != View.VISIBLE) {
mLoading.setVisibility(View.VISIBLE);
}
break;
// case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://第一帧
// break;
// case TXLiveConstants.PLAY_EVT_PLAY_END://播放结束
// break;
case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取视频宽高
// float width = bundle.getInt("EVT_PARAM1", 0);
// float height = bundle.getInt("EVT_PARAM2", 0);
// L.e(TAG, "流---width----->" + width);
// L.e(TAG, "流---height----->" + height);
// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
// int targetH = 0;
// if (width / height > 0.5625f) {//横屏 9:16=0.5625
// targetH = (int) (mVideoView.getWidth() / width * height);
// } else {
// targetH = ViewGroup.LayoutParams.MATCH_PARENT;
// }
// if (targetH != params.height) {
// params.height = targetH;
// params.addRule(RelativeLayout.CENTER_IN_PARENT);
// mVideoView.requestLayout();
// }
break;
case TXLiveConstants.PLAY_ERR_NET_DISCONNECT://播放失败
case TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND:
ToastUtil.show(mContext.getString(R.string.live_play_error));
break;
}
}
@Override
public void onNetStatus(Bundle bundle) {
}
}

View File

@ -8,11 +8,6 @@ import android.os.Bundle;
import android.util.TypedValue;
import android.view.ViewGroup;
import com.tencent.rtmp.ITXLivePushListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePushConfig;
import com.tencent.rtmp.TXLivePusher;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
@ -22,11 +17,11 @@ import com.yunbao.live.R;
* 连麦推流小窗口 腾讯sdk
*/
public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder implements ITXLivePushListener {
public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder {
private static final String TAG = "LiveLinkMicPushTxViewHolder";
private TXLivePusher mLivePusher;
private TXLivePushConfig mLivePushConfig;
// private TXLivePusher mLivePusher;
// private TXLivePushConfig mLivePushConfig;
public LiveLinkMicPushTxViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@ -39,7 +34,7 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
@Override
public void init() {
mLivePusher = new TXLivePusher(mContext);
/* mLivePusher = new TXLivePusher(mContext);
mLivePushConfig = new TXLivePushConfig();
mLivePushConfig.setVideoFPS(15);//视频帧率
mLivePushConfig.setVideoEncodeGop(1);//GOP大小
@ -55,7 +50,7 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
mLivePusher.setConfig(mLivePushConfig);
mLivePusher.setMirror(true);
mLivePusher.setPushListener(this);
mLivePusher.setMicVolume(4f);
mLivePusher.setMicVolume(4f);*/
}
@ -66,16 +61,16 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
*/
@Override
public void startPush(String pushUrl) {
if (mLivePusher != null) {
/* if (mLivePusher != null) {
mLivePusher.startCameraPreview((TXCloudVideoView) findViewById(R.id.camera_preview));
mLivePusher.startPusher(pushUrl);
}
}*/
}
@Override
public void release() {
mLivePushListener = null;
if (mLivePusher != null) {
/* if (mLivePusher != null) {
mLivePusher.stopPusher();
mLivePusher.stopScreenCapture();
mLivePusher.stopCameraPreview(false);
@ -85,70 +80,26 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
if (mLivePushConfig != null) {
mLivePushConfig.setPauseImg(null);
}
mLivePushConfig = null;
mLivePushConfig = null;*/
}
@Override
public void pause() {
mPaused = true;
if (mStartPush && mLivePusher != null) {
/*if (mStartPush && mLivePusher != null) {
mLivePusher.pausePusher();
}
}*/
}
@Override
public void resume() {
if (mPaused && mStartPush && mLivePusher != null) {
/*if (mPaused && mStartPush && mLivePusher != null) {
mLivePusher.resumePusher();
}
}*/
mPaused = false;
}
@Override
public void onPushEvent(int e, Bundle bundle) {
if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
if (mLivePushListener != null) {
mLivePushListener.onPushFailed();
}
} else if (e == TXLiveConstants.PUSH_ERR_OPEN_MIC_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
if (mLivePushListener != null) {
mLivePushListener.onPushFailed();
}
} else if (e == TXLiveConstants.PUSH_ERR_NET_DISCONNECT || e == TXLiveConstants.PUSH_ERR_INVALID_ADDRESS) {
L.e(TAG, "网络断开,推流失败------>");
if (mLivePushListener != null) {
mLivePushListener.onPushFailed();
}
} else if (e == TXLiveConstants.PUSH_WARNING_HW_ACCELERATION_FAIL) {
L.e(TAG, "不支持硬件加速------>");
if (mLivePushConfig != null && mLivePusher != null) {
mLivePushConfig.setHardwareAcceleration(TXLiveConstants.ENCODE_VIDEO_SOFTWARE);
mLivePusher.setConfig(mLivePushConfig);
}
} else if (e == TXLiveConstants.PUSH_EVT_FIRST_FRAME_AVAILABLE) {//预览成功
L.e(TAG, "mStearm--->初始化完毕");
if (mLivePushListener != null) {
mLivePushListener.onPreviewStart();
}
} else if (e == TXLiveConstants.PUSH_EVT_PUSH_BEGIN) {//推流成功
L.e(TAG, "mStearm--->推流成功");
if (!mStartPush) {
mStartPush = true;
if (mLivePushListener != null) {
mLivePushListener.onPushStart();
}
}
}
}
@Override
public void onNetStatus(Bundle bundle) {
}
private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue();
resources.openRawResource(id, value);

View File

@ -11,10 +11,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.tencent.live2.V2TXLiveDef;
import com.tencent.live2.V2TXLivePlayer;
import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.DpUtil;
@ -35,8 +31,8 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
private ViewGroup mLeftContainer;
private ViewGroup mRightContainer;
private RelativeLayout mPkContainer;
public static TXCloudVideoView mVideoView;
private V2TXLivePlayer mPlayer;
// public static TXCloudVideoView mVideoView;
// private V2TXLivePlayer mPlayer;
private View mLoading;
private ImageView mCover;
@ -78,7 +74,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
mPkContainer = (RelativeLayout) findViewById(R.id.pk_container);
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
// mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
leave = (ImageView) findViewById(R.id.leave);
mLoading = findViewById(R.id.loading);
mCover = (ImageView) findViewById(R.id.cover);
@ -129,14 +125,14 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
*/
@Override
public void play(String url,int playModel) {
mPlayer = new V2TXLivePlayerImpl(mContext);
/* mPlayer = new V2TXLivePlayerImpl(mContext);
if (TextUtils.isEmpty(url) || mVideoView == null) {
return;
}
mPlayer.setRenderView(mVideoView);
mPlayer.startPlay(url);
mPlayer.startPlay(url);*/
// mPlayer.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFit);
onPrepared();
@ -152,7 +148,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
public void release() {
mEnd = true;
mStarted = false;
mPlayer.stopPlay();
// mPlayer.stopPlay();
L.e(TAG, "release------->");
}
@ -169,20 +165,20 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void stopPlay2() {
if (mPlayer != null) {
/*if (mPlayer != null) {
mPlayer.stopPlay();
}
}*/
}
public static void setViewUP() {
Log.i("", "整理");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
// params.height = contexts.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.height = vHeight;
params.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
params.addRule(RelativeLayout.ALIGN_TOP);*/
// mVideoView.requestLayout();
}
/**
@ -206,17 +202,17 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
if (landscape == 2) {
Log.i("收到socket--->", "还原916");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/* RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
mVideoView.requestLayout();
mVideoView.requestLayout();*/
} else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
mVideoView.requestLayout();*/
}
hideCover();
}
@ -224,12 +220,12 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void setPkview() {
Log.i("收到socket--->", "变成169");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
mVideoView.requestLayout();*/
}
@Override
@ -239,18 +235,18 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
if (landscape == 2) {
Log.i("收到socket--->", "还原916");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
mVideoView.requestLayout();
mVideoView.requestLayout();*/
} else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
mVideoView.requestLayout();*/
}
}
@ -322,7 +318,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void changeToLeft() {
if (mVideoView != null) {
/* if (mVideoView != null) {
//
// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mVideoView.getWidth() / 2, DpUtil.dp2px(250));
@ -336,7 +332,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
}
}*/
if (mLoading != null && mLeftContainer != null) {
ViewParent viewParent = mLoading.getParent();
if (viewParent != null) {
@ -351,11 +347,11 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void changeToBig() {
if (mVideoView != null) {
/*if (mVideoView != null) {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mVideoView.setLayoutParams(params);
}
}*/
if (mLoading != null && mRoot != null) {
ViewParent viewParent = mLoading.getParent();
if (viewParent != null) {
@ -370,10 +366,10 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void onResume() {
if (!mPausedPlay && mPaused && mVideoView != null) {
/* if (!mPausedPlay && mPaused && mVideoView != null) {
// mVideoView.runInForeground();
// mVideoView.start();
}
}*/
mPaused = false;
}
@ -393,24 +389,24 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
//全屏
@Override
public void fullScreen() {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/* RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
params.addRule(RelativeLayout.ALIGN_TOP);
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270);
mVideoView.requestLayout();
mVideoView.requestLayout();*/
}
//小屏
@Override
public void smallScreen() {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
/* RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
mVideoView.requestLayout();
mVideoView.requestLayout();*/
}

View File

@ -1,545 +0,0 @@
package com.yunbao.live.views;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.ITXLivePlayListener;
import com.tencent.rtmp.TXLivePlayConfig;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.L;
import com.yunbao.live.R;
import com.yunbao.common.http.LiveHttpConsts;
import com.yunbao.common.http.LiveHttpUtil;
/**
* Created by cxf on 2018/10/10.
* 直播间播放器 腾讯播放器
*/
public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXLivePlayListener {
private static final String TAG = "LiveTxPlayViewHolder";
private ViewGroup mRoot;
private ViewGroup mSmallContainer;
private ViewGroup mLeftContainer;
private ViewGroup mRightContainer;
private ViewGroup mPkContainer;
private TXCloudVideoView mVideoView;
private View mLoading;
private ImageView mCover;
private V2TXLivePlayer mPlayer;
private boolean mPaused;//是否切后台了
private boolean mStarted;//是否开始了播放
private boolean mEnd;//是否结束了播放
private boolean mPausedPlay;//是否被动暂停了播放
private boolean mChangeToLeft;
private boolean mChangeToAnchorLinkMic;
private String mUrl;
private int mPlayType;
private HttpCallback mGetTxLinkMicAccUrlCallback;
private Handler mHandler;
private int mVideoLastProgress;
public LivePlayTxViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
}
@Override
public void setPkview() {
}
@Override
public void setPkEndview() {
}
@Override
public void setDrMicInfo(UserBean u) {
}
@Override
public void setLiveBeanLandscape(int landscape) {
}
@Override
public void endPk() {
}
@Override
public void endpk(String liveUid) {
}
@Override
public void initSwEngine(String liveUid) {
}
@Override
public void removeLiveUid(String uid) {
}
@Override
public void removeDetailView() {
}
@Override
public void setPkView(String liveUid) {
}
@Override
public void claerDrPkInfoView() {
}
@Override
public void endLiveMic() {
}
@Override
protected int getLayoutId() {
return R.layout.view_live_play_tx;
}
@Override
public void init() {
mRoot = (ViewGroup) findViewById(R.id.root);
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
mPkContainer = (ViewGroup) findViewById(R.id.pk_container);
mLoading = findViewById(R.id.loading);
mCover = (ImageView) findViewById(R.id.cover);
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
// mPlayer.setPlayListener(this);
// mPlayer.setPlayerView(mVideoView);
// mPlayer.enableHardwareDecode(false);
// 设置画面渲染方向
// mPlayer.setRenderRotation(TXLiveConstants.RENDER_ROTATION_LANDSCAPE);
TXLivePlayConfig playConfig = new TXLivePlayConfig();
playConfig.setAutoAdjustCacheTime(true);
playConfig.setMaxAutoAdjustCacheTime(5.0f);
playConfig.setMinAutoAdjustCacheTime(1.0f);
// mPlayer.setConfig(playConfig);
}
@Override
public void onPlayEvent(int e, Bundle bundle) {
if (mEnd) {
return;
}
// switch (e) {
// case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://播放开始
// if (mLoading != null && mLoading.getVisibility() == View.VISIBLE) {
// mLoading.setVisibility(View.INVISIBLE);
// }
// break;
// case TXLiveConstants.PLAY_EVT_PLAY_LOADING:
// if (mLoading != null && mLoading.getVisibility() != View.VISIBLE) {
// mLoading.setVisibility(View.VISIBLE);
// }
// break;
// case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://第一帧
// hideCover();
// break;
// case TXLiveConstants.PLAY_EVT_PLAY_END://播放结束
// replay();
// break;
// case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取视频宽高
// if (mChangeToLeft || mChangeToAnchorLinkMic) {
// return;
// }
// float width = bundle.getInt("EVT_PARAM1", 0);
// float height = bundle.getInt("EVT_PARAM2", 0);
// L.e(TAG, "流---width----->" + width);
// L.e(TAG, "流---height----->" + height);
// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
// int targetH = 0;
// if (width >= height) {//横屏 9:16=0.5625
// targetH = (int) (mVideoView.getWidth() / width * height);
// } else {
// targetH = ViewGroup.LayoutParams.MATCH_PARENT;
// }
// if (targetH != params.height) {
// params.height = targetH;
// params.gravity = Gravity.TOP;
// params.topMargin = 230;
// mVideoView.requestLayout();
// }
//
// break;
// case TXLiveConstants.PLAY_ERR_NET_DISCONNECT://播放失败
// case TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND:
// ToastUtil.show(mContext.getString(R.string.live_play_error));
// break;
// case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS:
// int progress = bundle.getInt("EVT_PLAY_PROGRESS_MS");
// if (mVideoLastProgress == progress) {
// replay();
// } else {
// mVideoLastProgress = progress;
// }
// break;
// default:break;
// }
}
@Override
public void onNetStatus(Bundle bundle) {
}
@Override
public void hideCover() {
if (mCover != null) {
mCover.animate().alpha(0).setDuration(500).start();
}
}
@Override
public void setCover(String coverUrl) {
if (mCover != null) {
ImgLoader.displayBlur(mContext, coverUrl, mCover);
}
}
@Override
public void fullScreen() {
}
@Override
public void smallScreen() {
}
/**
* 循环播放
*/
private void replay() {
if (mStarted && mPlayer != null) {
// mPlayer.seek(0);
// mPlayer.resume();
}
}
/**
* 暂停播放
*/
@Override
public void pausePlay() {
if (!mPausedPlay) {
mPausedPlay = true;
if (!mPaused) {
if (mPlayer != null) {
// mPlayer.pause();
}
}
if (mCover != null) {
mCover.setAlpha(1f);
if (mCover.getVisibility() != View.VISIBLE) {
mCover.setVisibility(View.VISIBLE);
}
}
}
}
/**
* 暂停播放后恢复
*/
@Override
public void resumePlay() {
if (mPausedPlay) {
mPausedPlay = false;
if (!mPaused) {
if (mPlayer != null) {
// mPlayer.resume();
}
}
hideCover();
}
}
/**
* 开始播放
*
* @param url 流地址
*/
@Override
public void play(String url,int playModel) {
url = "webrtc://5664.liveplay.myqcloud.com/live/5664_harchar1";
mPlayer = new V2TXLivePlayerImpl(mContext);
mPlayer.setRenderView(mVideoView);
mPlayer.setObserver(new V2TXLivePlayerObserver() {
@Override
public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
Log.d(TAG, "[Player] onError: player-" + player + " code-" + code + " msg-" + msg + " info-" + extraInfo);
}
@Override
public void onVideoPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle bundle) {
Log.d(TAG, "[Player] onVideoPlayStatusUpdate: player-" + player + ", status-" + status + ", reason-" + reason);
}
@Override
public void onWarning(V2TXLivePlayer v2TXLivePlayer, int i, String s, Bundle bundle) {
Log.d(TAG, "[Player] Override: player-" + v2TXLivePlayer + ", i-" + i + ", s-" + s);
}
@Override
public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveDef.V2TXLiveVideoFrame v2TXLiveVideoFrame) {
super.onRenderVideoFrame(player, v2TXLiveVideoFrame);
Log.d(TAG, "[Player] onRenderVideoFrame: player-" + player + ", v2TXLiveVideoFrame-" + v2TXLiveVideoFrame);
}
});
int result = mPlayer.startPlay(url);
Log.d(TAG, "startPlay : " + result);
// if (TextUtils.isEmpty(url)) {
// return;
// }
// int playType = -1;
// if (url.startsWith("rtmp://")) {
// playType = TXLivePlayer.PLAY_TYPE_LIVE_RTMP;
// } else if (url.endsWith(".flv")) {
// playType = TXLivePlayer.PLAY_TYPE_LIVE_FLV;
// } else if (url.endsWith(".m3u8")) {
// playType = TXLivePlayer.PLAY_TYPE_VOD_HLS;
// } else if (url.endsWith(".mp4")) {
// playType = TXLivePlayer.PLAY_TYPE_VOD_MP4;
// }
// if (playType == -1) {
// ToastUtil.show(R.string.live_play_error_2);
// return;
// }
// if (mPlayer != null) {
// int result = mPlayer.startPlay(url);
// if (result == 0) {
mStarted = true;
// mUrl = url;
// mPlayType = playType;
// }
// }
L.e(TAG, "play----url--->" + url);
}
@Override
public void switchStream(String url, int playModel) {
}
@Override
public void stopPlay() {
mChangeToLeft = false;
mChangeToAnchorLinkMic = false;
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
if (mCover != null) {
mCover.setAlpha(1f);
if (mCover.getVisibility() != View.VISIBLE) {
mCover.setVisibility(View.VISIBLE);
}
}
stopPlay2();
}
@Override
public void stopPlay2() {
if (mPlayer != null) {
mPlayer.stopPlay();
}
}
@Override
public void release() {
mEnd = true;
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
mHandler = null;
LiveHttpUtil.cancel(LiveHttpConsts.GET_TX_LINK_MIC_ACC_URL);
if (mPlayer != null) {
mPlayer.stopPlay();
// mPlayer.setPlayListener(null);
}
mPlayer = null;
L.e(TAG, "release------->");
}
@Override
public ViewGroup getSmallContainer() {
return mSmallContainer;
}
@Override
public ViewGroup getRightContainer() {
return mRightContainer;
}
@Override
public ViewGroup getPkContainer() {
return mPkContainer;
}
@Override
public void changeToLeft() {
// mChangeToLeft = true;
// if (mVideoView != null) {
// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
// params.width = mVideoView.getWidth() / 2;
// params.height = DpUtil.dp2px(250);
// params.topMargin = DpUtil.dp2px(130);
// mVideoView.setLayoutParams(params);
// }
// if (mLoading != null && mLeftContainer != null) {
// ViewParent viewParent = mLoading.getParent();
// if (viewParent != null) {
// ((ViewGroup) viewParent).removeView(mLoading);
// }
// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
// params.gravity = Gravity.CENTER;
// mLoading.setLayoutParams(params);
// mLeftContainer.addView(mLoading);
// }
}
@Override
public void changeToBig() {
// mChangeToLeft = false;
// if (mVideoView != null) {
// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
// params.width = ViewGroup.LayoutParams.MATCH_PARENT;
// params.height = ViewGroup.LayoutParams.MATCH_PARENT;
// params.topMargin = 0;
// mVideoView.setLayoutParams(params);
// }
// if (mLoading != null && mRoot != null) {
// ViewParent viewParent = mLoading.getParent();
// if (viewParent != null) {
// ((ViewGroup) viewParent).removeView(mLoading);
// }
// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
// params.gravity = Gravity.CENTER;
// mLoading.setLayoutParams(params);
// mRoot.addView(mLoading);
// }
}
@Override
public void onResume() {
if (!mPausedPlay && mPaused && mPlayer != null) {
// mPlayer.resume();
}
mPaused = false;
}
@Override
public void onPause() {
if (!mPausedPlay && mPlayer != null) {
// mPlayer.pause();
}
mPaused = true;
}
@Override
public void onDestroy() {
release();
}
/**
* 腾讯sdk连麦时候切换低延时流
*/
public void onLinkMicTxAccEvent(boolean linkMic) {
if (mStarted && mPlayer != null && !TextUtils.isEmpty(mUrl)) {
mPlayer.stopPlay();
if (linkMic) {
if (mGetTxLinkMicAccUrlCallback == null) {
mGetTxLinkMicAccUrlCallback = new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
String accUrl = obj.getString("streamUrlWithSignature");
if (!TextUtils.isEmpty(accUrl) && mPlayer != null) {
L.e(TAG, "低延时流----->" + accUrl);
mPlayer.startPlay(accUrl);
}
}
}
}
};
}
LiveHttpUtil.getTxLinkMicAccUrl(mUrl, mGetTxLinkMicAccUrlCallback);
} else {
mPlayer.startPlay(mUrl);
}
}
}
/**
* 设置主播连麦模式
*
* @param anchorLinkMic
*/
public void setAnchorLinkMic(final boolean anchorLinkMic, int delayTime) {
// if (mVideoView == null) {
// return;
// }
// if (mHandler == null) {
// mHandler = new Handler();
// }
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// mChangeToAnchorLinkMic = anchorLinkMic;
// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
// Log.d("aaaaa",""+anchorLinkMic);
// if (anchorLinkMic) {
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
// params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
// params.gravity = Gravity.TOP;
// } else {
// params.height = ViewGroup.LayoutParams.MATCH_PARENT;
// params.topMargin = 0;
// params.gravity = Gravity.CENTER;
// }
// mVideoView.setLayoutParams(params);
// }
// }, delayTime);
}
}

View File

@ -25,8 +25,6 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.tencent.rtmp.ITXLivePushListener;
import com.tencent.rtmp.TXLiveConstants;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@ -73,7 +71,7 @@ import io.rong.message.TextMessage;
* 腾讯云直播推流
*/
public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITXLivePushListener {
public class LivePushSwViewHolder extends AbsRyLivePushViewHolder {
private int mMeiBaiVal;//基础美颜 美白
private int mMoPiVal;//基础美颜 磨皮
private int mHongRunVal;//基础美颜 红润
@ -529,8 +527,9 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
// rtcRoom = null;
}
/*
@Override
public void onPushEvent(int e, Bundle bundle) {
public void onPushEvent(int e, Bundle bundle) {
if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
@ -562,7 +561,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void onNetStatus(Bundle bundle) {
}
}*/
private void aheadOfScheduleEndPK(String pkUid, String uname, String pkname) {
if (!isPk) {

View File

@ -20,13 +20,7 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tencent.liteav.device.TXDeviceManager;
import com.tencent.rtmp.ITXLivePushListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.tencent.trtc.TRTCCloud;
import com.tencent.trtc.TRTCCloudDef;
import com.tencent.trtc.TRTCCloudListener;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@ -49,16 +43,13 @@ import com.yunbao.live.socket.SocketSendBean;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import static com.tencent.trtc.TRTCCloudDef.TRTC_APP_SCENE_LIVE;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG;
/**
* Created by cxf on 2018/10/7.
* 腾讯云直播推流
*/
public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLivePushListener {
public class LivePushTxViewHolder extends AbsLivePushViewHolder {
private int mMeiBaiVal;//基础美颜 美白
private int mMoPiVal;//基础美颜 磨皮
@ -66,9 +57,9 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
private String mBgmPath;//背景音乐路径
private Bitmap mFilterBmp;
public static TRTCCloud mTRTCCloud;
private TXDeviceManager mTXDeviceManager;
private TRTCCloudDef.TRTCParams mTRTCParams;
// public static TRTCCloud mTRTCCloud;
// private TXDeviceManager mTXDeviceManager;
// private TRTCCloudDef.TRTCParams mTRTCParams;
private Handler mMainHandler;
public TencentTRTCBeautyManager tencentTRTCBeautyManager;
public static Context contexts;
@ -89,19 +80,19 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
@Override
public void init() {
super.init();
mPreView = (TXCloudVideoView) findViewById(R.id.camera_preview);
mPreView1 = (TXCloudVideoView) findViewById(R.id.camera_preview1);
dr1_preview = (TXCloudVideoView) findViewById(R.id.dr1_preview);
dr2_preview = (TXCloudVideoView) findViewById(R.id.dr2_preview);
dr3_preview = (TXCloudVideoView) findViewById(R.id.dr3_preview);
dr4_preview = (TXCloudVideoView) findViewById(R.id.dr4_preview);
mPreView = (StyledPlayerView) findViewById(R.id.camera_preview);
mPreView1 = (StyledPlayerView) findViewById(R.id.camera_preview1);
dr1_preview = (StyledPlayerView) findViewById(R.id.dr1_preview);
dr2_preview = (StyledPlayerView) findViewById(R.id.dr2_preview);
dr3_preview = (StyledPlayerView) findViewById(R.id.dr3_preview);
dr4_preview = (StyledPlayerView) findViewById(R.id.dr4_preview);
leave = (ImageView) findViewById(R.id.leave);
dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
dr_pk_view.setVisibility(View.GONE);
btn_close = (TextView) findViewById(R.id.btn_close);
mTRTCCloud = TRTCCloud.sharedInstance(mContext);
// mTRTCCloud = TRTCCloud.sharedInstance(mContext);
mMainHandler = new Handler(Looper.getMainLooper());
btn_close.setOnClickListener(new View.OnClickListener() {
/* btn_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh()?"是否要斷開連麥?":"Do you want to disconnect Link?", new DialogUitl.SimpleCallback() {
@ -227,7 +218,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
tencentTRTCBeautyManager.textureDestoryed();
}
});
enterRoom();
enterRoom();*/
}
@ -260,7 +251,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
} else {
mCameraFront = true;
}
mTXDeviceManager.switchCamera(mCameraFront);
// mTXDeviceManager.switchCamera(mCameraFront);
}
/**
@ -288,13 +279,13 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
@Override
public void startPush(String pushUrl) {
mTRTCCloud.enterRoom(mTRTCParams, TRTC_APP_SCENE_LIVE);
mTRTCCloud.startPublishing(getLiveStream(), TRTC_VIDEO_STREAM_TYPE_BIG);
// mTRTCCloud.enterRoom(mTRTCParams, TRTC_APP_SCENE_LIVE);
// mTRTCCloud.startPublishing(getLiveStream(), TRTC_VIDEO_STREAM_TYPE_BIG);
startCountDown();
}
protected class TRTCCloudImplListener extends TRTCCloudListener {
/* protected class TRTCCloudImplListener extends TRTCCloudListener {
private WeakReference<Context> mContext;
@ -426,7 +417,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
// Bitmap bitmap = decodeResource(mContext.getResources(), R.mipmap.bg_live_tx_pause);
mTRTCCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_DEFAULT);
}
}*/
@Override
public void onPause() {
@ -480,10 +471,10 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
public void release() {
super.release();
LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
mTRTCCloud = null;
// mTRTCCloud = null;
}
@Override
/* @Override
public void onPushEvent(int e, Bundle bundle) {
if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
@ -519,7 +510,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
@Override
public void onNetStatus(Bundle bundle) {
}
}*/
private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue();

View File

@ -19,11 +19,6 @@ import android.widget.FrameLayout;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tencent.rtmp.ITXLivePushListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePushConfig;
import com.tencent.rtmp.TXLivePusher;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.utils.DownloadUtil;
@ -47,11 +42,11 @@ import cn.qqtheme.framework.util.ScreenUtils;
* 腾讯云直播推流
*/
public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder implements ITXLivePushListener, SurfaceHolder.Callback,
public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder implements SurfaceHolder.Callback,
SurfaceTexture.OnFrameAvailableListener, Camera.PreviewCallback {
private TXLivePusher mLivePusher;
private TXLivePushConfig mLivePushConfig;
// private TXLivePusher mLivePusher;
// private TXLivePushConfig mLivePushConfig;
private int mMeiBaiVal;//基础美颜 美白
private int mMoPiVal;//基础美颜 磨皮
private int mHongRunVal;//基础美颜 红润
@ -87,7 +82,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
super.init();
String mBeauty360TieZhiUrl= CommonAppConfig.getInstance().getBeauty360TieZhiUrl();
mLivePusher = new TXLivePusher(mContext);
/* mLivePusher = new TXLivePusher(mContext);
mLivePushConfig = new TXLivePushConfig();
mLivePushConfig.setVideoFPS(15);//视频帧率
mLivePushConfig.setVideoEncodeGop(1);//GOP大小
@ -108,7 +103,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
mLivePusher.setMicVolume(4f);
mLivePusher.setConfig(mLivePushConfig);
mLivePusher.setPushListener(this);
mLivePusher.setPushListener(this);*/
initBeauty360();
@ -141,7 +136,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
String mBeautySdkType= CommonAppConfig.getInstance().getBeautySdkType();
Log.d("mBeautySdkType",mBeautySdkType);
if ("2".equals(mBeautySdkType)) {
mLivePusher.setVideoProcessListener(new TXLivePusher.VideoCustomProcessListener() {
/* mLivePusher.setVideoProcessListener(new TXLivePusher.VideoCustomProcessListener() {
@Override
public int onTextureCustomProcess(int i, int i1, int i2) {
@ -154,7 +149,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
public void onTextureDestoryed() {
}
});
mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);
mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);*/
} else if ("3".equals(mBeautySdkType)){
//遍历解压缩后的文件夹获取所有贴纸列表
@ -174,7 +169,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
download360TieZhi(mBeauty360TieZhiUrl,CommonAppConfig.TIEZHI_360_NAME+".zip");
}
}else {
mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);
// mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);
}
}
@ -296,7 +291,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
*/
@Override
public void toggleCamera() {
if (mLivePusher != null) {
/* if (mLivePusher != null) {
if (mFlashOpen) {
toggleFlash();
}
@ -304,7 +299,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
// mPreviewUtils.switchCamera();
mCameraFront = !mCameraFront;
mLivePusher.setMirror(mCameraFront);
}
}*/
}
@ -317,14 +312,14 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
ToastUtil.show(mContext.getString(R.string.live_open_flash));
return;
}
if (mLivePusher != null) {
/* if (mLivePusher != null) {
boolean open = !mFlashOpen;
// if (mLivePusher.turnOnFlashLight(open)) {
// mFlashOpen = open;
// }
// mPreviewUtils.switchCameraFlashLight();
mFlashOpen = open;
}
}*/
}
/**
@ -334,10 +329,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
*/
@Override
public void startPush(String pushUrl) {
if (mLivePusher != null) {
/*if (mLivePusher != null) {
//启动 RTMP 推流 0-启动成功1-启动失败
mLivePusher.startPusher(pushUrl);
}
}*/
startCountDown();
}
@ -345,10 +340,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
@Override
public void onPause() {
mPaused = true;
if (mStartPush && mLivePusher != null) {
/* if (mStartPush && mLivePusher != null) {
mLivePusher.pauseBGM();
mLivePusher.pausePusher();
}
}*/
// mPreviewUtils.pause();
@ -363,10 +358,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
@Override
public void onResume() {
if (mPaused && mStartPush && mLivePusher != null) {
/* if (mPaused && mStartPush && mLivePusher != null) {
mLivePusher.resumePusher();
mLivePusher.resumeBGM();
}
}*/
mPaused = false;
//camera
@ -405,33 +400,33 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
}
@Override
public void startBgm(String path) {
if (mLivePusher != null) {
/*if (mLivePusher != null) {
boolean result = mLivePusher.playBGM(path);
if (result) {
mBgmPath = path;
}
}
}*/
}
@Override
public void pauseBgm() {
if (mLivePusher != null) {
/*if (mLivePusher != null) {
mLivePusher.pauseBGM();
}
}*/
}
@Override
public void resumeBgm() {
if (mLivePusher != null) {
/* if (mLivePusher != null) {
mLivePusher.resumeBGM();
}
}*/
}
@Override
public void stopBgm() {
if (mLivePusher != null) {
/*if (mLivePusher != null) {
mLivePusher.stopBGM();
}
}*/
mBgmPath = null;
}
@ -446,7 +441,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
public void release() {
super.release();
LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
if (mLivePusher != null) {
/* if (mLivePusher != null) {
mLivePusher.stopBGM();
mLivePusher.stopPusher();
// mLivePusher.stopScreenCapture();
@ -459,52 +454,12 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
if (mLivePushConfig != null) {
mLivePushConfig.setPauseImg(null);
}
mLivePushConfig = null;
mLivePushConfig = null;*/
// mPreviewUtils.freeRes();
}
@Override
public void onPushEvent(int e, Bundle bundle) {
// String msg = bundle.getString(TXLiveConstants.EVT_DESCRIPTION);
Log.d("onPushEvent",""+e+" "+bundle.toString());
if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
} else if (e == TXLiveConstants.PUSH_ERR_OPEN_MIC_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_2));
} else if (e == TXLiveConstants.PUSH_ERR_NET_DISCONNECT || e == TXLiveConstants.PUSH_ERR_INVALID_ADDRESS) {
L.e(TAG, "网络断开,推流失败------>");
} else if (e == TXLiveConstants.PUSH_WARNING_HW_ACCELERATION_FAIL) {
L.e(TAG, "不支持硬件加速------>");
if (mLivePushConfig != null && mLivePusher != null) {
mLivePushConfig.setHardwareAcceleration(TXLiveConstants.ENCODE_VIDEO_SOFTWARE);
mLivePusher.setConfig(mLivePushConfig);
}
} else if (e == TXLiveConstants.PUSH_EVT_FIRST_FRAME_AVAILABLE) {//预览成功
L.e(TAG, "mStearm--->初始化完毕");
if (mLivePushListener != null) {
mLivePushListener.onPreviewStart();
}
} else if (e == TXLiveConstants.PUSH_EVT_PUSH_BEGIN) {//推流成功
L.e(TAG, "mStearm--->推流成功");
if (!mStartPush) {
mStartPush = true;
if (mLivePushListener != null) {
mLivePushListener.onPushStart();
}
}
}
}
@Override
public void onNetStatus(Bundle bundle) {
}
private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue();
@ -684,10 +639,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
if (mLivePushListener != null) {
mLivePushListener.onPreviewStart();
}
if (mLivePusher != null)
/*if (mLivePusher != null)
{
// int ret=mLivePusher.sendCustomVideoData(mPreviewUtils.getSkinSoftenByte(), TXLivePusher.RGB_RGBA, mPreviewUtils.getCameraHeight(), mPreviewUtils.getCameraWidth());
}
}*/
}
@Override

View File

@ -1,8 +1,5 @@
package com.yunbao.live.views;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
import static com.yunbao.live.views.LivePushTxViewHolder.mTRTCCloud;
import android.app.Dialog;
import android.content.Context;
@ -23,9 +20,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lzy.okgo.model.Response;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.tencent.trtc.TRTCCloudDef;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.LiveRoomTypeBean;
@ -221,7 +215,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
} else if (i == R.id.btn_locaiton) {
switchLocation();
} else if (i == R.id.btn_horizontally) {
TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
/* TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
if (mrr == 0) {
mrr = 1;
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_ENABLE;
@ -231,7 +225,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_DISABLE;
mTRTCCloud.setVideoEncoderMirror(false);
}
mTRTCCloud.setLocalRenderParams(t);
mTRTCCloud.setLocalRenderParams(t);*/
}
}
@ -499,7 +493,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
L.e("tx开播", "createRoom------->" + info[0]);
final CommonAppConfig appConfig = CommonAppConfig.getInstance();
UserBean u = appConfig.getUserBean();
V2TIMManager.getInstance().createGroup(V2TIMManager.GROUP_TYPE_AVCHATROOM, "g" + appConfig.getUid(), "直播", new V2TIMSendCallback<String>() {
/* V2TIMManager.getInstance().createGroup(V2TIMManager.GROUP_TYPE_AVCHATROOM, "g" + appConfig.getUid(), "直播", new V2TIMSendCallback<String>() {
@Override
public void onProgress(int progress) {
@ -520,7 +514,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
ToastUtil.show("开播失败,联系客服。");
}
}
});
});*/
} else {
ToastUtil.show(msg);

View File

@ -1,231 +0,0 @@
package com.yunbao.live.views;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXVodPlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.live.R;
/**
* Created by cxf on 2018/10/29.
* 直播记录播放页面
*/
public class LiveRecordPlayViewHolder extends AbsViewHolder implements ITXLivePlayListener {
private static final String TAG = "VideoPlayViewHolder";
private TXCloudVideoView mVideoView;
private View mLoading;
private TXVodPlayer mPlayer;
private boolean mClickPaused;
private boolean mPaused;
private boolean mStarted;
private boolean mEnd;
private long mDuration;
private long mCurTime;
private int mProgress;
private ActionListener mActionListener;
public LiveRecordPlayViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
}
@Override
protected int getLayoutId() {
return R.layout.view_live_record_play;
}
@Override
public void init() {
mLoading = findViewById(R.id.loading);
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
mVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
mPlayer = new TXVodPlayer(mContext);
mPlayer.setPlayerView(mVideoView);
mPlayer.setAutoPlay(true);
mPlayer.setPlayListener(this);
}
@Override
public void onPlayEvent(int e, Bundle bundle) {
switch (e) {
case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS://进度条
if (mActionListener != null) {
int duration = bundle.getInt("EVT_PLAY_DURATION_MS");
if (mDuration != duration) {
mDuration = duration;
mActionListener.onDuration(duration);
}
int curTime = bundle.getInt("EVT_PLAY_PROGRESS_MS");
if (mCurTime != curTime) {
mCurTime = curTime;
mActionListener.onCurTime(curTime);
}
int progress = curTime * 100 / duration;
if (mProgress != progress) {
mProgress = progress;
mActionListener.onProgress(progress);
}
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_BEGIN:
if (!mEnd) {
L.e(TAG, "VideoPlayView------>播放开始");
if (mLoading != null && mLoading.getVisibility() == View.VISIBLE) {
mLoading.setVisibility(View.INVISIBLE);
}
} else {
release();
}
break;
case TXLiveConstants.PLAY_ERR_NET_DISCONNECT:
case TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND:
ToastUtil.show(mContext.getString(R.string.live_play_error));
break;
case TXLiveConstants.PLAY_EVT_PLAY_LOADING:
if (mLoading != null && mLoading.getVisibility() != View.VISIBLE) {
mLoading.setVisibility(View.VISIBLE);
}
break;
case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME:
L.e(TAG, "VideoPlayView------>第一帧");
break;
case TXLiveConstants.PLAY_EVT_PLAY_END:
onReplay();
break;
case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION:
int width = bundle.getInt("EVT_PARAM1", 0);
int height = bundle.getInt("EVT_PARAM2", 0);
if (mVideoView != null && width >= height) {//横屏视频
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
float rate = ((float) width) / height;
params.height = (int) (mVideoView.getWidth() / rate);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
mVideoView.requestLayout();
}
break;
}
}
@Override
public void onNetStatus(Bundle bundle) {
L.e("onNetStatus-------->");
}
/**
* 循环播放
*/
private void onReplay() {
if (!mEnd && mStarted && mPlayer != null) {
mPlayer.seek(0);
mPlayer.resume();
}
}
/**
* 开始播放
*/
public void play(String url) {
if (!mEnd && mPlayer != null) {
if (mStarted) {
mPlayer.stopPlay(false);
}
mPlayer.startPlay(url);
mStarted = true;
L.e(TAG, "play------->" + url);
}
}
public void release() {
mActionListener = null;
mEnd = true;
if (mPlayer != null) {
mPlayer.stopPlay(true);
}
mPlayer = null;
if (mVideoView != null) {
mVideoView.onDestroy();
}
mVideoView = null;
L.e(TAG, "release------->");
}
public void clickPause() {
mClickPaused = true;
if (!mEnd && mPlayer != null) {
mPlayer.pause();
}
if (mActionListener != null) {
mActionListener.onClickPause();
}
}
public void clickResume() {
if (mClickPaused) {
mClickPaused = false;
if (!mEnd && mPlayer != null) {
mPlayer.resume();
}
if (mActionListener != null) {
mActionListener.onClickResume();
}
}
}
/**
* 跳转到视频流指定时间点.
* 可实现视频快进,快退,进度条跳转等功能.
*
* @param time 视频流时间点,小数点后为毫秒
*/
public void seekTo(float time) {
if (!mEnd && mPlayer != null) {
mPlayer.seek(time);
}
}
public void setActionListener(ActionListener actionListener) {
mActionListener = actionListener;
}
public interface ActionListener {
void onProgress(int progress);
void onDuration(long duration);
void onCurTime(long curTime);
void onClickPause();
void onClickResume();
}
@Override
public void onPause() {
mPaused = true;
if (!mEnd && !mClickPaused && mPlayer != null) {
mPlayer.pause();
}
}
@Override
public void onResume() {
if (mPaused) {
mPaused = false;
if (!mEnd && !mClickPaused && mPlayer != null) {
mPlayer.resume();
}
}
}
}

View File

@ -16,7 +16,6 @@ import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRecordPlayActivity;
import com.yunbao.live.adapter.LiveRecordAdapter;
import com.yunbao.live.bean.LiveRecordBean;
import com.yunbao.common.http.LiveHttpConsts;
@ -127,7 +126,7 @@ public class LiveRecordViewHolder extends AbsUserHomeViewHolder implements OnIte
if (mActionListener != null) {
UserBean userBean = mActionListener.getUserBean();
if (userBean != null) {
LiveRecordPlayActivity.forward(mContext, url, userBean);
// LiveRecordPlayActivity.forward(mContext, url, userBean);
}
}
} else {

View File

@ -1355,9 +1355,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
topBanner1 = (Banner) findViewById(R.id.top_banner1);
topBanner2 = (Banner) findViewById(R.id.top_banner2);
if (LivePushTxViewHolder.mTRTCCloud != null ) {
/* if (LivePushTxViewHolder.mTRTCCloud != null ) {
fans_btn.setVisibility(View.GONE);
}
}*/
mPkRankTopIcon.setVisibility(View.GONE);
goto_room_view = (LinearLayout) findViewById(R.id.goto_room_view);
goto_room_view.setVisibility(View.GONE);
@ -2343,9 +2343,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (d_pk_view != null) {
d_pk_view.setVisibility(View.GONE);
}
if (LivePushTxViewHolder.mTRTCCloud != null ) {
/* if (LivePushTxViewHolder.mTRTCCloud != null ) {
fans_btn.setVisibility(View.GONE);
}
}*/
mRedVal.setVisibility(View.GONE);
mBlueVal.setVisibility(View.GONE);
mPkRankTopIcon.setVisibility(View.GONE);
@ -3444,10 +3444,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
});
initPkRank();
if (LivePushTxViewHolder.mTRTCCloud != null) {
} else {
}
}
public void setDelOtherInfo() {

View File

@ -7,12 +7,12 @@
android:orientation="vertical"
tools:context=".activity.LiveTRTCAnchorActivity">
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/live_cloud_view_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/live_cloud_view_two"
android:background="@color/color_yellow"
android:layout_alignParentBottom="true"

View File

@ -6,7 +6,7 @@
android:background="#333"
>
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/camera_preview"
android:layout_width="match_parent"

View File

@ -7,7 +7,7 @@
android:layout_height="match_parent"
>
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -9,7 +9,7 @@
android:layout_height="match_parent"
android:orientation="horizontal">
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@ -28,13 +28,13 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/dr1_preview"
android:layout_width="100dp"
android:layout_height="125dp"
android:background="@mipmap/live_icon_vacancy" />
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/dr2_preview"
android:layout_width="100dp"
android:layout_height="125dp"
@ -47,13 +47,13 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/dr3_preview"
android:layout_width="100dp"
android:layout_height="125dp"
android:background="@mipmap/live_icon_vacancy" />
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/dr4_preview"
android:layout_width="100dp"
android:layout_height="125dp"
@ -63,7 +63,7 @@
</LinearLayout>
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/camera_preview1"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
>
<com.tencent.rtmp.ui.TXCloudVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<ProgressBar
android:id="@+id/loading"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim_loading"
android:indeterminateOnly="true"
/>
</RelativeLayout>

View File

@ -7,9 +7,6 @@ import android.view.View;
import android.widget.EditText;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
@ -74,7 +71,7 @@ public class EditNameActivity extends AbsActivity implements View.OnClickListene
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u != null) {
u.setUserNiceName(content);
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
/* V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
v2TIMUserFullInfo.setNickname(content);
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
@Override
@ -84,7 +81,7 @@ public class EditNameActivity extends AbsActivity implements View.OnClickListene
@Override
public void onSuccess() {
}
});
});*/
}
Intent intent = getIntent();
intent.putExtra(Constants.NICK_NAME, content);

View File

@ -20,9 +20,6 @@ import com.lzy.okgo.model.Response;
import com.sahooz.library.Country;
import com.sahooz.library.CountryPicker;
import com.sahooz.library.OnPick;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
@ -150,7 +147,7 @@ public class EditProfileActivity extends AbsActivity {
mUserBean.setAvatar(obj.getString("avatar"));
mUserBean.setAvatarThumb(obj.getString("avatarThumb"));
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
/* V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
@Override
@ -160,7 +157,7 @@ public class EditProfileActivity extends AbsActivity {
@Override
public void onSuccess() {
}
});
});*/
}
EventBus.getDefault().post(new UpdateFieldEvent());
}

View File

@ -52,11 +52,6 @@ import com.jakewharton.rxbinding3.view.RxView;
import com.lxj.xpopup.XPopup;
import com.lzf.easyfloat.EasyFloat;
import com.lzf.easyfloat.permission.PermissionUtils;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMSDKConfig;
import com.tencent.imsdk.v2.V2TIMSDKListener;
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.QiniuLog;
import com.yunbao.common.glide.ImgLoader;
@ -468,7 +463,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
ConfigBean configBean = CommonAppConfig.getInstance().getConfig();
mUrlCsd = configBean.getCustomerServerUrl();
init();
initTXIM();
if (mViewPager != null) {
mViewPager.setCurrentItem(0);
mTabButtonGroup.setCurPosition(0);
@ -744,105 +738,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
}
//初始化腾讯im
private void initTXIM() {
//登录腾讯云服务器
CommonAppConfig.getInstance();
IMLoginModel userInfo = IMLoginManager.get(this).getUserInfo();
if (userInfo == null) {
RouteUtil.forwardLoginInvalid("登錄信息已失效,請重新登錄");
return;
}
// 1. IM 控制台获取应用 SDKAppID详情请参考 SDKAppID
// 2. 初始化 config 对象
V2TIMSDKConfig config = new V2TIMSDKConfig();
// 3. 指定 log 输出级别详情请参考 SDKConfig
config.setLogLevel(V2TIMSDKConfig.V2TIM_LOG_INFO);
// 4. 初始化 SDK 并设置 V2TIMSDKListener 的监听对象
// initSDK SDK 会自动连接网络网络连接状态可以在 V2TIMSDKListener 回调里面监听
V2TIMManager.getInstance().initSDK(this, GenerateTestUserSig.SDKAPPID, new V2TIMSDKConfig(), new V2TIMSDKListener() {
// 5. 监听 V2TIMSDKListener 回调
@Override
public void onConnecting() {
// 正在连接到腾讯云服务器
Log.i("tx", "正在连接到腾讯云服务器");
}
@Override
public void onConnectSuccess() {
Log.i("tx", "已经成功连接到腾讯云服务器");
}
@Override
public void onConnectFailed(int code, String error) {
// 连接腾讯云服务器失败
Log.i("tx", "连接腾讯云服务器失败");
}
@Override
public void onKickedOffline() {
super.onKickedOffline();
Log.i("tx", "腾讯云服务器踢出登录");
CommonAppConfig.getInstance().clearLoginInfo();
LoginActivity.forward();
}
@Override
public void onUserSigExpired() {
super.onUserSigExpired();
Log.i("tx", "登录过期了");
V2TIMManager.getInstance().login(userInfo.getId() + "", GenerateTestUserSig.genTestUserSig(userInfo.getId() + ""), new V2TIMCallback() {
@Override
public void onSuccess() {
Log.i("tx", "登录成功");
}
@Override
public void onError(int code, String desc) {
Log.i("tx", "登录失败: code = " + code + " desc = " + desc);
}
});
}
});
//登录腾讯云服务器
V2TIMManager.getInstance().login(userInfo.getId() + "", GenerateTestUserSig.genTestUserSig(userInfo.getId() + ""), new V2TIMCallback() {
@Override
public void onSuccess() {
Log.i("tx", "登录成功");
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
v2TIMUserFullInfo.setNickname(userInfo.getUserNicename());
v2TIMUserFullInfo.setFaceUrl(userInfo.getAvatarThumb());
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
@Override
public void onError(int code, String desc) {
Log.i("vdxdffd", "换失败" + desc);
}
@Override
public void onSuccess() {
Log.i("vdxdffd", "换成功");
}
});
}
@Override
public void onError(int code, String desc) {
Log.i("tx", "登录失败: code = " + code + " desc = " + desc);
}
});
}
// });
public void mainClick(View v) {

View File

@ -27,9 +27,6 @@ import androidx.annotation.RequiresApi;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
@ -310,7 +307,7 @@ public class MyWebViewActivity extends AbsActivity {
JSONObject obj = JSON.parseObject(info[0]);
bean.setAvatar(obj.getString("avatar"));
bean.setAvatarThumb(obj.getString("avatarThumb"));
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
/* V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
@Override
@ -320,7 +317,7 @@ public class MyWebViewActivity extends AbsActivity {
@Override
public void onSuccess() {
}
});
});*/
}
}
}

View File

@ -7,9 +7,6 @@ import android.widget.EditText;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.makeramen.roundedimageview.RoundedImageView;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.UserBean;
@ -84,7 +81,7 @@ public class OneLoginActivity extends AbsActivity {
bean.setAvatar(obj.getString("avatar"));
bean.setAvatarThumb(obj.getString("avatarThumb"));
ImgLoader.displayAvatar(mContext, CommonAppConfig.getInstance().getUserBean().getAvatar(), avatar);
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
/*V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
@Override
@ -94,7 +91,7 @@ public class OneLoginActivity extends AbsActivity {
@Override
public void onSuccess() {
}
});
});*/
}
}
}

View File

@ -29,9 +29,6 @@ import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@ -192,7 +189,7 @@ public class RewardActivity extends AbsActivity {
JSONObject obj = JSON.parseObject(info[0]);
bean.setAvatar(obj.getString("avatar"));
bean.setAvatarThumb(obj.getString("avatarThumb"));
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
/* V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
@Override
@ -202,7 +199,7 @@ public class RewardActivity extends AbsActivity {
@Override
public void onSuccess() {
}
});
});*/
}
}
}

View File

@ -15,9 +15,6 @@ import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import com.tencent.ugc.TXVideoEditConstants;
import com.tencent.ugc.TXVideoEditer;
import com.tencent.ugc.TXVideoInfoReader;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.utils.DialogUitl;
@ -47,11 +44,8 @@ import java.util.List;
*/
public class VideoEditActivity extends AbsActivity implements
VideoProcessViewHolder.ActionListener,//预处理控件点击取消回调
TXVideoEditer.TXVideoProcessListener, //视频编辑前预处理进度回调
TXVideoEditer.TXThumbnailListener, //视频编辑前预处理中生成每一帧缩略图回调
TXVideoEditer.TXVideoPreviewListener,
TXVideoEditer.TXVideoGenerateListener {
VideoProcessViewHolder.ActionListener//预处理控件点击取消回调
{
private static final String TAG = "VideoEditActivity";
private static final int STATUS_NONE = 0;
@ -73,7 +67,7 @@ public class VideoEditActivity extends AbsActivity implements
private View mBtnNext;
private View mBtnPlay;
private ObjectAnimator mPlayBtnAnimator;//暂停按钮的动画
private TXVideoEditer mVideoEditer;
// private TXVideoEditer mVideoEditer;
private List<Bitmap> mBitmapList;//视频每一帧的缩略图
private long mVideoDuration;//视频总长度
private String mOriginVideoPath;//原视频路径
@ -135,12 +129,12 @@ public class VideoEditActivity extends AbsActivity implements
finish();
return;
}
mVideoEditer = new TXVideoEditer(mContext);
/* mVideoEditer = new TXVideoEditer(mContext);
mVideoEditer.setVideoPath(mOriginVideoPath);
mVideoEditer.setVideoProcessListener(this);
mVideoEditer.setThumbnailListener(this);
mVideoEditer.setTXVideoPreviewListener(this);
mVideoEditer.setVideoGenerateListener(this);
mVideoEditer.setVideoGenerateListener(this);*/
mCutStartTime = 0;
mCutEndTime = mVideoDuration;
startPreProcess();
@ -181,25 +175,12 @@ public class VideoEditActivity extends AbsActivity implements
switch (mPLayStatus) {
case STATUS_PLAY:
mPLayStatus = STATUS_PAUSE;
if (mVideoEditer != null) {
mVideoEditer.pausePlay();
}
break;
case STATUS_PAUSE:
mPLayStatus = STATUS_PLAY;
if (mVideoEditer != null) {
mVideoEditer.resumePlay();
}
break;
case STATUS_PREVIEW_AT_TIME:
mPLayStatus = STATUS_PLAY;
if (mVideoEditer != null) {
if (mPreviewAtTime > mCutStartTime && mPreviewAtTime < mCutEndTime) {
mVideoEditer.startPlayFromTime(mPreviewAtTime, mCutEndTime);
} else {
mVideoEditer.startPlayFromTime(mCutStartTime, mCutEndTime);
}
}
break;
}
if (mPLayStatus == STATUS_PAUSE) {
@ -217,14 +198,6 @@ public class VideoEditActivity extends AbsActivity implements
* 开启视频预览
*/
private void startVideoPreview() {
if (mVideoEditer == null) {
return;
}
FrameLayout layout = (FrameLayout) findViewById(R.id.video_container);
TXVideoEditConstants.TXPreviewParam param = new TXVideoEditConstants.TXPreviewParam();
param.videoView = layout;
param.renderMode = TXVideoEditConstants.PREVIEW_RENDER_MODE_FILL_EDGE;
mVideoEditer.initWithPreview(param);
startPlay();
}
@ -232,75 +205,11 @@ public class VideoEditActivity extends AbsActivity implements
* 开始播放
*/
private void startPlay() {
if (mVideoEditer != null) {
mPLayStatus = STATUS_PLAY;
mVideoEditer.startPlayFromTime(mCutStartTime, mCutEndTime);
hidePlayBtn();
}
}
/**
* 预览播放回调
*/
@Override
public void onPreviewProgress(int time) {
if (mPLayStatus == STATUS_PLAY && mCutViewHolder != null) {
mCutViewHolder.onVideoProgressChanged(time);
}
}
/**
* 预览播放回调
*/
@Override
public void onPreviewFinished() {
if (mPLayStatus == STATUS_PLAY) {
startPlay();//播放结束后重新开始播放
}
}
/**
* 生成视频进度回调
*/
@Override
public void onGenerateProgress(float progress) {
if (mVideoGenerateViewHolder != null) {
mVideoGenerateViewHolder.setProgress((int) (progress * 100));
}
}
/**
* 生成视频结束回调
*/
@Override
public void onGenerateComplete(TXVideoEditConstants.TXGenerateResult result) {
L.e(TAG, "onGenerateComplete------->");
if (result.retCode == TXVideoEditConstants.GENERATE_RESULT_OK) {
L.e(TAG, "onGenerateComplete------->生成视频成功");
ToastUtil.show(R.string.video_generate_success);
switch (mSaveType) {
case Constants.VIDEO_SAVE_SAVE://仅保存
saveGenerateVideoInfo();
break;
case Constants.VIDEO_SAVE_PUB://仅发布
VideoPublishActivity.forward(mContext, mGenerateVideoPath, mSaveType,mMusicBean != null ? mMusicBean.getId() : 0);
break;
case Constants.VIDEO_SAVE_SAVE_AND_PUB://保存并发布
saveGenerateVideoInfo();
VideoPublishActivity.forward(mContext, mGenerateVideoPath, mSaveType,mMusicBean != null ? mMusicBean.getId() : 0);
break;
}
finish();
} else {
ToastUtil.show(R.string.video_generate_failed);
if (mVideoGenerateViewHolder != null) {
mVideoGenerateViewHolder.removeFromParent();
}
if (mBtnNext != null) {
mBtnNext.setEnabled(true);
}
}
}
/**
* 把新生成的视频保存到ContentProvider,在选择上传的时候能找到
@ -345,39 +254,6 @@ public class VideoEditActivity extends AbsActivity implements
mMusicViewHolder.setActionListener(new VideoMusicViewHolder.ActionListener() {
@Override
public void onChooseMusic(MusicBean bean) {
if (mVideoEditer != null && bean != null) {
String bgmPath = bean.getLocalPath();
if (TextUtils.isEmpty(bgmPath)) {
return;
}
long bgmDuration = 0;
if (mMetadataRetriever == null) {
mMetadataRetriever = new MediaMetadataRetriever();
}
try {
mMetadataRetriever.setDataSource(bgmPath);
String duration = mMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
bgmDuration = Long.parseLong(duration);
} catch (Exception e) {
bgmDuration = 0;
e.printStackTrace();
}
if (bgmDuration == 0) {
return;
}
bean.setDuration(bgmDuration);
mVideoEditer.setBGM(bgmPath);
mVideoEditer.setBGMVolume(0.8f);
if (mHasOriginBgm) {
mVideoEditer.setVideoVolume(0);
}
mMusicBean = bean;
if (mVolumeViewHolder != null) {
mVolumeViewHolder.setMusicBean(bean);
}
mVideoEditer.stopPlay();
startPlay();
}
}
@Override
@ -406,34 +282,19 @@ public class VideoEditActivity extends AbsActivity implements
@Override
public void onOriginalVolumeChanged(float value) {
if (mVideoEditer != null) {
mVideoEditer.setVideoVolume(value);
}
}
@Override
public void onBgmVolumeChanged(float value) {
if (mVideoEditer != null) {
mVideoEditer.setBGMVolume(value);
}
}
@Override
public void onBgmCancelClick() {
if (mVideoEditer != null) {
mVideoEditer.setVideoVolume(0.8f);
mVideoEditer.setBGM(null);
mVideoEditer.stopPlay();
startPlay();
}
mMusicBean = null;
}
@Override
public void onBgmCutTimeChanged(long startTime, long endTime) {
if (mVideoEditer != null) {
mVideoEditer.setBGMStartTime(startTime, endTime);
}
}
});
mVolumeViewHolder.addToParent();
@ -456,9 +317,6 @@ public class VideoEditActivity extends AbsActivity implements
@Override
public void onFilterChanged(Bitmap bitmap) {
if (mVideoEditer != null) {
mVideoEditer.setFilter(bitmap);
}
}
});
mFilterViewHolder.addToParent();
@ -487,41 +345,20 @@ public class VideoEditActivity extends AbsActivity implements
public void onCutTimeChanged(long startTime, long endTime) {
mCutStartTime = startTime;
mCutEndTime = endTime;
if (mVideoEditer != null) {
mVideoEditer.setCutFromTime(startTime, endTime);
}
}
@Override
public void onSpecialStart(int effect, long currentTimeMs) {
if (mVideoEditer != null) {
if (mPLayStatus == STATUS_NONE || mPLayStatus == STATUS_PREVIEW_AT_TIME) {
mVideoEditer.startPlayFromTime(mPreviewAtTime, mCutEndTime);
} else if (mPLayStatus == STATUS_PAUSE) {
mVideoEditer.resumePlay();
}
mPLayStatus = STATUS_PLAY;
mVideoEditer.startEffect(effect, currentTimeMs);
}
hidePlayBtn();
}
@Override
public void onSpecialEnd(int effect, long currentTimeMs) {
if (mVideoEditer != null) {
mVideoEditer.pausePlay();
mPLayStatus = STATUS_PAUSE;
mVideoEditer.stopEffect(effect, currentTimeMs);
}
showPlayBtn();
}
@Override
public void onSpecialCancel(long currentTimeMs) {
if (mVideoEditer != null) {
mVideoEditer.deleteLastEffect();
previewAtTime(currentTimeMs);
}
}
});
mCutViewHolder.addToParent();
@ -531,10 +368,6 @@ public class VideoEditActivity extends AbsActivity implements
private void previewAtTime(long currentTimeMs) {
if (mVideoEditer != null) {
mVideoEditer.pausePlay();
mVideoEditer.previewAtTime(currentTimeMs);
}
mPLayStatus = STATUS_PREVIEW_AT_TIME;
mPreviewAtTime = currentTimeMs;
showPlayBtn();
@ -591,7 +424,7 @@ public class VideoEditActivity extends AbsActivity implements
*/
private void startGenerateVideo() {
L.e(TAG, "startGenerateVideo------->生成视频");
if (mVideoEditer == null) {
/* if (mVideoEditer == null) {
return;
}
mBtnNext.setEnabled(false);
@ -607,7 +440,7 @@ public class VideoEditActivity extends AbsActivity implements
mVideoGenerateViewHolder.addToParent();
mVideoEditer.setCutFromTime(mCutStartTime, mCutEndTime);
mGenerateVideoPath = StringUtil.generateVideoOutputPath();
mVideoEditer.generateVideo(TXVideoEditConstants.VIDEO_COMPRESSED_720P, mGenerateVideoPath);
mVideoEditer.generateVideo(TXVideoEditConstants.VIDEO_COMPRESSED_720P, mGenerateVideoPath);*/
}
private void showGroup() {
@ -678,7 +511,7 @@ public class VideoEditActivity extends AbsActivity implements
if (mCutViewHolder != null) {
mCutViewHolder.release();
}
if (mVideoEditer != null) {
/* if (mVideoEditer != null) {
mVideoEditer.deleteAllEffect();
mVideoEditer.stopPlay();
mVideoEditer.cancel();
@ -687,7 +520,7 @@ public class VideoEditActivity extends AbsActivity implements
mVideoEditer.setTXVideoPreviewListener(null);
mVideoEditer.setVideoGenerateListener(null);
mVideoEditer.release();
}
}*/
if (mVideoProcessViewHolder != null) {
mVideoProcessViewHolder.setActionListener(null);
}
@ -705,7 +538,7 @@ public class VideoEditActivity extends AbsActivity implements
mHandler = null;
mMetadataRetriever = null;
mFilterViewHolder = null;
mVideoEditer = null;
// mVideoEditer = null;
mMusicViewHolder = null;
mVolumeViewHolder = null;
mCutViewHolder = null;
@ -719,19 +552,19 @@ public class VideoEditActivity extends AbsActivity implements
protected void onPause() {
super.onPause();
mPaused = true;
if (mVideoEditer != null && mPLayStatus == STATUS_PLAY) {
mVideoEditer.pausePlay();
}
// if (mVideoEditer != null && mPLayStatus == STATUS_PLAY) {
// mVideoEditer.pausePlay();
// }
}
@Override
protected void onResume() {
super.onResume();
if (mPaused) {
if (mVideoEditer != null && mPLayStatus == STATUS_PLAY) {
mVideoEditer.resumePlay();
}
}
// if (mPaused) {
// if (mVideoEditer != null && mPLayStatus == STATUS_PLAY) {
// mVideoEditer.resumePlay();
// }
// }
mPaused = false;
}
@ -756,14 +589,14 @@ public class VideoEditActivity extends AbsActivity implements
@Override
public void run() {
try {
TXVideoEditConstants.TXVideoInfo info = TXVideoInfoReader.getInstance().getVideoFileInfo(mOriginVideoPath);
/* TXVideoEditConstants.TXVideoInfo info = TXVideoInfoReader.getInstance().getVideoFileInfo(mOriginVideoPath);
if (mHandler != null) {
if (info == null) {
mHandler.sendEmptyMessage(MyHandler.ERROR);
} else {
mHandler.sendEmptyMessage(MyHandler.SUCCESS);
}
}
}*/
} catch (Exception e) {
if (mHandler != null) {
mHandler.sendEmptyMessage(MyHandler.ERROR);
@ -778,7 +611,7 @@ public class VideoEditActivity extends AbsActivity implements
*/
private void doPreProcess() {
try {
if (mVideoEditer != null) {
/* if (mVideoEditer != null) {
mBitmapList = new ArrayList<>();
int thumbnailCount = (int) Math.floor(mVideoDuration / 1000f);
TXVideoEditConstants.TXThumbnail thumbnail = new TXVideoEditConstants.TXThumbnail();
@ -787,7 +620,7 @@ public class VideoEditActivity extends AbsActivity implements
thumbnail.height = 100;
mVideoEditer.setThumbnail(thumbnail);
mVideoEditer.processVideo();
}
}*/
} catch (Exception e) {
e.printStackTrace();
processFailed();
@ -796,48 +629,6 @@ public class VideoEditActivity extends AbsActivity implements
}
/**
* 录制结束后视频预处理进度回调
*/
@Override
public void onProcessProgress(float progress) {
int p = (int) (progress * 100);
if (p > 0 && p <= 100) {
if (mVideoProcessViewHolder != null) {
mVideoProcessViewHolder.setProgress(p);
}
}
}
/**
* 录制结束后视频预处理的回调
*/
@Override
public void onProcessComplete(TXVideoEditConstants.TXGenerateResult result) {
if (result.retCode == TXVideoEditConstants.GENERATE_RESULT_OK) {
if (mVideoProcessViewHolder != null && mVideoProcessViewHolder.getProgress() == 0) {
if (!mSdkError) {
mSdkError = true;
sdkProgressError();
}
} else {
processCompleted();
}
} else {
L.e(TAG, "视频预处理错误------->" + result.descMsg);
processFailed();
}
}
/**
* 制结束后获取缩略图的回调
*/
@Override
public void onThumbnail(int i, long l, Bitmap bitmap) {
if (mBitmapList != null) {
mBitmapList.add(new SoftReference<>(bitmap).get());
}
}
/**

View File

@ -21,11 +21,6 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePlayConfig;
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.activity.AbsActivity;
@ -61,7 +56,7 @@ import top.zibin.luban.OnRenameListener;
* 视频发布
*/
public class VideoPublishActivity extends AbsActivity implements ITXLivePlayListener, View.OnClickListener {
public class VideoPublishActivity extends AbsActivity implements View.OnClickListener {
public static void forward(Context context, String videoPath, int saveType, int musicId) {
@ -75,8 +70,8 @@ public class VideoPublishActivity extends AbsActivity implements ITXLivePlayList
private static final String TAG = "VideoPublishActivity";
private TextView mNum;
private TextView mLocation;
private TXCloudVideoView mTXCloudVideoView;
private TXLivePlayer mPlayer;
// private TXCloudVideoView mTXCloudVideoView;
// private TXLivePlayer mPlayer;
private String mVideoPath;
private boolean mPlayStarted;//播放是否开始了
private boolean mPaused;//生命周期暂停
@ -149,7 +144,7 @@ public class VideoPublishActivity extends AbsActivity implements ITXLivePlayList
mLocation.setText(CommonAppConfig.getInstance().getCity());
mCheckBox = findViewById(R.id.checkbox);
mCheckBox.setOnClickListener(this);
mTXCloudVideoView = findViewById(R.id.video_view);
/* mTXCloudVideoView = findViewById(R.id.video_view);
mPlayer = new TXLivePlayer(mContext);
mPlayer.setConfig(new TXLivePlayConfig());
mPlayer.setPlayerView(mTXCloudVideoView);
@ -160,75 +155,50 @@ public class VideoPublishActivity extends AbsActivity implements ITXLivePlayList
int result = mPlayer.startPlay(mVideoPath, TXLivePlayer.PLAY_TYPE_LOCAL_VIDEO);
if (result == 0) {
mPlayStarted = true;
}
}*/
}
@Override
public void onPlayEvent(int e, Bundle bundle) {
switch (e) {
case TXLiveConstants.PLAY_EVT_PLAY_END://播放结束
onReplay();
break;
case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION:
onVideoSizeChanged(bundle.getInt("EVT_PARAM1", 0), bundle.getInt("EVT_PARAM2", 0));
break;
case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS:
int progress = bundle.getInt("EVT_PLAY_PROGRESS_MS");
if (mVideoLastProgress == progress) {
onReplay();
} else {
mVideoLastProgress = progress;
}
break;
}
}
@Override
public void onNetStatus(Bundle bundle) {
}
/**
* 获取到视频宽高回调
*/
public void onVideoSizeChanged(float videoWidth, float videoHeight) {
if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
/*if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTXCloudVideoView.getLayoutParams();
if (videoWidth / videoHeight > 0.5625f) {//横屏 9:16=0.5625
params.height = (int) (mTXCloudVideoView.getWidth() / videoWidth * videoHeight);
params.gravity = Gravity.CENTER;
mTXCloudVideoView.requestLayout();
}
}
}*/
}
/**
* 循环播放
*/
private void onReplay() {
if (mPlayStarted && mPlayer != null) {
/*if (mPlayStarted && mPlayer != null) {
mPlayer.seek(0);
mPlayer.resume();
}
}*/
}
@Override
protected void onPause() {
super.onPause();
mPaused = true;
if (mPlayStarted && mPlayer != null) {
/* if (mPlayStarted && mPlayer != null) {
mPlayer.pause();
}
}*/
}
@Override
protected void onResume() {
super.onResume();
if (mPaused && mPlayStarted && mPlayer != null) {
/*if (mPaused && mPlayStarted && mPlayer != null) {
mPlayer.resume();
}
}*/
mPaused = false;
}
@ -236,17 +206,17 @@ public class VideoPublishActivity extends AbsActivity implements ITXLivePlayList
CommonHttpUtil.cancel(CommonHttpConsts.GET_CONFIG);
VideoHttpUtil.cancel(VideoHttpConsts.SAVE_UPLOAD_VIDEO_INFO);
mPlayStarted = false;
if (mPlayer != null) {
/*if (mPlayer != null) {
mPlayer.stopPlay(false);
mPlayer.setPlayListener(null);
}
}*/
if (mUploadStrategy != null) {
mUploadStrategy.cancel();
}
// if (mMobShareUtil != null) {
// mMobShareUtil.release();
// }
mPlayer = null;
// mPlayer = null;
mUploadStrategy = null;
// mMobShareUtil = null;
}

View File

@ -7,7 +7,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.tencent.ugc.TXVideoEditConstants;
//import com.tencent.ugc.TXVideoEditConstants;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.views.AbsViewHolder;
@ -170,7 +170,7 @@ public class VideoEditCutViewHolder extends AbsViewHolder implements View.OnClic
int color = 0;
int effect = 0;
int i = v.getId();
if (i == R.id.btn_special_1) {
/* if (i == R.id.btn_special_1) {
color = 0xAA1FBCB6;
effect = TXVideoEditConstants.TXEffectType_ROCK_LIGHT;
@ -186,7 +186,7 @@ public class VideoEditCutViewHolder extends AbsViewHolder implements View.OnClic
color = 0xAAEC5F9B;
effect = TXVideoEditConstants.TXEffectType_SOUL_OUT;
}
}*/
if (mColorfulProgress != null) {
mColorfulProgress.startMark(color);
}
@ -205,7 +205,7 @@ public class VideoEditCutViewHolder extends AbsViewHolder implements View.OnClic
mSpecialStartMark = false;
int effect = 0;
int i = v.getId();
if (i == R.id.btn_special_1) {
/*if (i == R.id.btn_special_1) {
effect = TXVideoEditConstants.TXEffectType_ROCK_LIGHT;
} else if (i == R.id.btn_special_2) {
@ -217,7 +217,7 @@ public class VideoEditCutViewHolder extends AbsViewHolder implements View.OnClic
} else if (i == R.id.btn_special_4) {
effect = TXVideoEditConstants.TXEffectType_SOUL_OUT;
}
}*/
if (mColorfulProgress != null) {
mColorfulProgress.endMark();
}

View File

@ -22,7 +22,6 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.google.android.exoplayer2.video.VideoSize;
import com.tencent.rtmp.TXLiveConstants;
import com.yunbao.common.utils.L;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.video.R;
@ -37,7 +36,7 @@ import com.yunbao.video.http.VideoHttpUtil;
public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickListener {
private StyledPlayerView mTXCloudVideoView;
private StyledPlayerView mPlayView;
private View mVideoCover;
private ExoPlayer mPlayer;
private boolean mPaused;//生命周期暂停
@ -72,9 +71,9 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
.build();
mCachePath = mContext.getCacheDir().getAbsolutePath();
mTXCloudVideoView = (StyledPlayerView) findViewById(R.id.placeholderView);
mTXCloudVideoView.setKeepContentOnPlayerReset(true);
mTXCloudVideoView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH);
mPlayView = (StyledPlayerView) findViewById(R.id.placeholderView);
mPlayView.setKeepContentOnPlayerReset(true);
mPlayView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH);
mPlayer = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
mPlayer.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
findViewById(R.id.root).setOnClickListener(this);
@ -98,11 +97,14 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
Player.Listener.super.onPlaybackStateChanged(playbackState);
if (playbackState == Player.STATE_READY) {
mPlayer.play();
onPlayEvent(TXLiveConstants.PLAY_EVT_PLAY_BEGIN, null);
onPlayEvent(1, null);
// onPlayEvent(TXLiveConstants.PLAY_EVT_PLAY_BEGIN, null);
} else if (playbackState == Player.STATE_BUFFERING) {
onPlayEvent(TXLiveConstants.PLAY_EVT_PLAY_LOADING, null);
onPlayEvent(2, null);
// onPlayEvent(TXLiveConstants.PLAY_EVT_PLAY_LOADING, null);
} else if (playbackState == Player.STATE_ENDED) {
onPlayEvent(TXLiveConstants.PLAY_EVT_PLAY_END, null);
onPlayEvent(3, null);
// onPlayEvent(TXLiveConstants.PLAY_EVT_PLAY_END, null);
}
}
@ -112,13 +114,15 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
Bundle bundle = new Bundle();
bundle.putInt("EVT_PARAM1", videoSize.width);
bundle.putInt("EVT_PARAM2", videoSize.height);
onPlayEvent(TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION, bundle);
onPlayEvent(4, bundle);
// onPlayEvent(TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION, bundle);
}
@Override
public void onRenderedFirstFrame() {
Player.Listener.super.onRenderedFirstFrame();
onPlayEvent(TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME, null);
onPlayEvent(5, null);
// onPlayEvent(TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME, null);
}
@Override
@ -133,7 +137,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
LogUtils.e(error);
}
});
mTXCloudVideoView.setPlayer(mPlayer);
mPlayView.setPlayer(mPlayer);
}
/**
@ -141,19 +145,19 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
*/
public void onPlayEvent(int e, Bundle bundle) {
switch (e) {
case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://加载完成开始播放的回调
case 1://加载完成开始播放的回调
mStartPlay = true;
if (mActionListener != null) {
mActionListener.onPlayBegin();
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_LOADING: //开始加载的回调
case 2: //开始加载的回调
if (mActionListener != null) {
mActionListener.onPlayLoading();
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_END://获取到视频播放完毕的回调
case 3://获取到视频播放完毕的回调
replay();
if (!mEndPlay) {
mEndPlay = true;
@ -162,7 +166,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
}
}
break;
case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://获取到视频首帧回调
case 5://获取到视频首帧回调
if (mActionListener != null) {
mActionListener.onFirstFrame();
}
@ -170,7 +174,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
mPlayer.pause();
}
break;
case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取到视频宽高回调
case 4://获取到视频宽高回调
onVideoSizeChanged(bundle.getInt("EVT_PARAM1", 0), bundle.getInt("EVT_PARAM2", 0));
break;
}
@ -180,17 +184,17 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
* 获取到视频宽高回调
*/
public void onVideoSizeChanged(float videoWidth, float videoHeight) {
if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mTXCloudVideoView.getLayoutParams();
if (mPlayView != null && videoWidth > 0 && videoHeight > 0) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPlayView.getLayoutParams();
int targetH = 0;
if (videoWidth / videoHeight > 0.5625f) {//横屏 9:16=0.5625
targetH = (int) (mTXCloudVideoView.getWidth() / videoWidth * videoHeight);
targetH = (int) (mPlayView.getWidth() / videoWidth * videoHeight);
} else {
targetH = ViewGroup.LayoutParams.MATCH_PARENT;
}
if (targetH != params.height) {
params.height = targetH;
mTXCloudVideoView.requestLayout();
mPlayView.requestLayout();
}
if (mVideoCover != null && mVideoCover.getVisibility() == View.VISIBLE) {
mVideoCover.setVisibility(View.INVISIBLE);

View File

@ -27,7 +27,7 @@
android:background="#000"
>
<com.tencent.rtmp.ui.TXCloudVideoView
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"