From f856188a689b32657885fda688a30e12734223bc Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 31 Oct 2022 15:48:42 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=94=B9=E4=B8=BAEXOPlayer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- live/build.gradle | 2 +- .../live/views/LivePlayRyViewHolder.java | 138 ++++-------------- .../main/res/layout/view_live_play_ksy.xml | 3 +- 3 files changed, 33 insertions(+), 110 deletions(-) diff --git a/live/build.gradle b/live/build.gradle index f8dddcdbd..e76f37fc2 100644 --- a/live/build.gradle +++ b/live/build.gradle @@ -1 +1 @@ -apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" } \ No newline at end of file +apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" implementation 'com.google.android.exoplayer:exoplayer-core:2.18.1' implementation 'com.google.android.exoplayer:exoplayer-rtsp:2.17.1' implementation 'com.google.android.exoplayer:exoplayer-ui:2.18.1' } \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 59a3cb96c..3d934d59f 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -18,6 +18,10 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import com.alibaba.fastjson.JSON; +import com.google.android.exoplayer2.ExoPlayer; +import com.google.android.exoplayer2.MediaItem; +import com.google.android.exoplayer2.ui.PlayerView; +import com.google.android.exoplayer2.ui.StyledPlayerView; import com.lzy.okserver.OkDownload; import com.lzy.okserver.download.DownloadTask; import com.tencent.live2.V2TXLiveDef; @@ -78,7 +82,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { private ViewGroup mLeftContainer; private ViewGroup mRightContainer; private RelativeLayout mPkContainer; - public static TXCloudVideoView mVideoView; + public static StyledPlayerView mVideoView; private View mLoading; private ImageView mCover; @@ -90,7 +94,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { private boolean mPausedPlay;//是否被动暂停了播放 public static int landscape; //1h 2s public static Context contexts; - public V2TXLivePlayer mPlayer; + public ExoPlayer mPlayer; public static FrameLayout ry_view; @@ -134,7 +138,7 @@ public class LivePlayRyViewHolder 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 = (StyledPlayerView) findViewById(R.id.video_view); ry_view = (FrameLayout) findViewById(R.id.ry_view); leave = (ImageView) findViewById(R.id.leave); mLoading = findViewById(R.id.loading); @@ -147,6 +151,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { params.height = vHeight; mPkContainer.requestLayout(); + mPlayer = new ExoPlayer.Builder(mContext) + .build(); + mVideoView.setPlayer(mPlayer); + } @Override @@ -192,109 +200,20 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { return; } - mPlayer = new V2TXLivePlayerImpl(mContext); if (TextUtils.isEmpty(url) || mVideoView == null) { return; } //mPlayer.setCacheParams(1.0f, 5.0f); - mPlayer.setObserver(new V2TXLivePlayerObserver() { - String TAG = "播放流"; - - @Override - public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { - super.onError(player, code, msg, extraInfo); - Log.i(TAG, "onError: player = " + player + ", code = " + code + ", msg = " + msg + ", extraInfo = " + extraInfo); - } - - @Override - public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { - super.onWarning(player, code, msg, extraInfo); - Log.i(TAG, "onWarning: " + "player = " + player + ", code = " + code + ", msg = " + msg + ", extraInfo = " + extraInfo); - if (code == 2105) { - // mPlayer.resumeVideo(); - // mPlayer.resumeAudio(); - mPlayer.stopPlay(); - mPlayer.startPlay(purl); - } - } - - @Override - public void onVideoPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle extraInfo) { - super.onVideoPlayStatusUpdate(player, status, reason, extraInfo); - //Log.i(TAG, "onVideoPlayStatusUpdate: " + "player = " + player + ", status = " + status + ", reason = " + reason + ", extraInfo = " + extraInfo); - } - - @Override - public void onAudioPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle extraInfo) { - super.onAudioPlayStatusUpdate(player, status, reason, extraInfo); - //Log.i(TAG, "onAudioPlayStatusUpdate: " + "player = " + player + ", status = " + status + ", reason = " + reason + ", extraInfo = " + extraInfo); - } - - @Override - public void onPlayoutVolumeUpdate(V2TXLivePlayer player, int volume) { - super.onPlayoutVolumeUpdate(player, volume); - - } - - @Override - public void onStatisticsUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayerStatistics statistics) { - super.onStatisticsUpdate(player, statistics); - Map taskMap = OkDownload.getInstance().getTaskMap(); - StringBuilder buffer = new StringBuilder(); - buffer.append("|"); - for (String key : taskMap.keySet()) { - DownloadTask task = taskMap.get(key); - buffer.append(task.progress.fileName).append(":"); - int status = task.progress.status; - switch (status) { - case 0: - buffer.append("无状态"); - break; - case 1: - buffer.append("等待"); - break; - case 2: - buffer.append("下载中:").append(task.progress.fraction); - break; - case 3: - buffer.append("暂停"); - break; - case 4: - buffer.append("错误"); - break; - case 5: - buffer.append("完成"); - break; - } - buffer.append("|"); - } - //Log.i(TAG, "onStatisticsUpdate: " + JSON.toJSONString(statistics) + " |当前下载数 : " + OkDownload.getInstance().getTaskMap().size() + buffer); - if (statistics.fps == 0) { - OkDownload.getInstance().pauseAll(); - } else { - OkDownload.getInstance().startAll(); - } - } - - @Override - public void onSnapshotComplete(V2TXLivePlayer player, Bitmap image) { - super.onSnapshotComplete(player, image); - } - - @Override - public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveDef.V2TXLiveVideoFrame videoFrame) { - super.onRenderVideoFrame(player, videoFrame); - } - - @Override - public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) { - super.onReceiveSeiMessage(player, payloadType, data); - } - }); - mPlayer.setRenderView(mVideoView); + if(mPlayer.isPlaying()){ + mPlayer.stop(); + mPlayer.release(); + } purl = url; - mPlayer.startPlay(url); + MediaItem item = MediaItem.fromUri(url); + mPlayer.setMediaItem(item); + mPlayer.prepare(); + mPlayer.play(); onPrepared(); } @@ -305,7 +224,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { mEnd = true; mStarted = false; if (mPlayer != null) { - mPlayer.stopPlay(); + mPlayer.stop(); + mPlayer.release(); } L.e(TAG, "release------->"); } @@ -319,7 +239,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } } if (mPlayer != null) { - mPlayer.stopPlay(); + mPlayer.stop(); + mPlayer.release(); } stopPlay2(); } @@ -508,7 +429,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.topMargin = 0; params.addRule(RelativeLayout.ALIGN_TOP); - mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270); + // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270); mVideoView.requestLayout(); } @@ -518,7 +439,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); params.height = vHeight; params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); - mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0); + // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0); params.addRule(RelativeLayout.ALIGN_TOP); mVideoView.requestLayout(); } @@ -565,10 +486,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { Log.e("ry", "退出多人房间成功"); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { - mPlayer.startPlay(purl); + mPlayer.setMediaItem(MediaItem.fromUri(purl)); Log.e("ry", mPlayer.isPlaying() + "purl" + purl); - if (mPlayer.isPlaying() != 1) { - mPlayer.startPlay(purl); + if (!mPlayer.isPlaying()) { + mPlayer.prepare(); + mPlayer.play(); } ry_view.removeAllViews(); onPrepared(); @@ -630,7 +552,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { for (RCRTCInputStream stream : data.getLiveStreams()) { if (stream.getMediaType() == RCRTCMediaType.VIDEO) { //暂停播放 - mPlayer.stopPlay(); + mPlayer.stop(); //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 diff --git a/live/src/main/res/layout/view_live_play_ksy.xml b/live/src/main/res/layout/view_live_play_ksy.xml index a9d4c4e45..8302e9bfd 100644 --- a/live/src/main/res/layout/view_live_play_ksy.xml +++ b/live/src/main/res/layout/view_live_play_ksy.xml @@ -8,9 +8,10 @@ > - Date: Mon, 31 Oct 2022 15:55:52 +0800 Subject: [PATCH 2/6] test --- .../live/views/LivePlayRyViewHolder.java | 2 +- .../live/views/PortraitLiveManager.java | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 3d934d59f..f2230631f 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -196,7 +196,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void play(String url) { Log.e("purl121", url); - if (TextUtils.isEmpty(url) || mVideoView == null) { + if (TextUtils.isEmpty(url) || mVideoView == null || true) { return; } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 67b717693..b3c61b5a9 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -238,19 +238,21 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe .setParametersModel(openParametersModel .setmLiveType(mLiveType) .setmLiveTypeVal(mLiveTypeVal))); - mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); - mLivePlayViewHolder.addToParent(); - mLivePlayViewHolder.subscribeActivityLifeCycle(); - mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); - mLiveRoomViewHolder.subscribeActivityLifeCycle(); - mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); - mLiveAudienceViewHolder.addToParent(); - mLiveRoomViewHolder.addToParent(); - mLiveAudienceViewHolder.subscribeActivityLifeCycle(); - mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); - mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null); + if (mLivePlayViewHolder == null) { + mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); + mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); + mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); + mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); + mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null); + mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); + mLivePlayViewHolder.addToParent(); + mLivePlayViewHolder.subscribeActivityLifeCycle(); + mLiveRoomViewHolder.subscribeActivityLifeCycle(); + mLiveAudienceViewHolder.addToParent(); + mLiveRoomViewHolder.addToParent(); + mLiveAudienceViewHolder.subscribeActivityLifeCycle(); + } - mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); //直播间背景 ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600); //ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); From 7e169e882d6b936b0c7a08ab153687c5b68b000e Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 31 Oct 2022 16:41:28 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=97=B4=E5=86=85?= =?UTF-8?q?=E5=AD=98=E4=BC=98=E5=8C=96=E7=A8=B3=E5=AE=9A=E5=88=B00.7G?= =?UTF-8?q?=E5=B7=A6=E5=8F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.gradle | 2 +- .../live/views/LivePlayRyViewHolder.java | 4 +- .../yunbao/live/views/LiveRoomViewHolder.java | 6 +- .../live/views/PortraitLiveManager.java | 105 ++++++++++-------- 4 files changed, 65 insertions(+), 52 deletions(-) diff --git a/config.gradle b/config.gradle index 65bb82468..0ce0c9db2 100644 --- a/config.gradle +++ b/config.gradle @@ -27,6 +27,6 @@ ext { // true表示谷歌支付 false isGooglePlay : true, //是否上报异常日志 - isUploadLog : true + isUploadLog : false ] } \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index f2230631f..c18162203 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -196,7 +196,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void play(String url) { Log.e("purl121", url); - if (TextUtils.isEmpty(url) || mVideoView == null || true) { + if (TextUtils.isEmpty(url) || mVideoView == null) { return; } @@ -207,7 +207,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { //mPlayer.setCacheParams(1.0f, 5.0f); if(mPlayer.isPlaying()){ mPlayer.stop(); - mPlayer.release(); } purl = url; MediaItem item = MediaItem.fromUri(url); @@ -240,7 +239,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } if (mPlayer != null) { mPlayer.stop(); - mPlayer.release(); } stopPlay2(); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index f667d1f5b..e841c0598 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1051,7 +1051,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }); } - + public void clearChat(){ + if(mLiveChatAdapter!=null){ + mLiveChatAdapter.clear(); + } + } public synchronized void showStart(StarChallengeStatusModel data) { boolean upData = false; if (mBannerList2 != null && mBannerList2.size() == 0) { diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index b3c61b5a9..fccb40f99 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -11,6 +11,7 @@ import android.content.Intent; import android.content.res.Configuration; import android.os.CountDownTimer; import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -220,7 +221,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe liveBack = mRootContainer.findViewById(R.id.live_back); mask = mRootContainer.findViewById(R.id.mask); } - + private static boolean test=true; @Override public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) { openParametersModel = new OpenParametersModel(); @@ -238,7 +239,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe .setParametersModel(openParametersModel .setmLiveType(mLiveType) .setmLiveTypeVal(mLiveTypeVal))); - if (mLivePlayViewHolder == null) { + if (mLivePlayViewHolder == null && test) { + test=false; mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); @@ -251,27 +253,30 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveAudienceViewHolder.addToParent(); mLiveRoomViewHolder.addToParent(); mLiveAudienceViewHolder.subscribeActivityLifeCycle(); + mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this); } + if(true) { + //直播间背景 + ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600); + //ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); + mask.setVisibility(View.VISIBLE); + mLivePlayViewHolder.setCover(data.getThumb()); + mLivePlayViewHolder.play(data.getPull()); + mLiveRoomViewHolder.clearChat(); + mLiveRoomViewHolder.setAvatar(data.getAvatar()); + mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); + mLiveRoomViewHolder.setName(data.getUserNiceName()); + mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); + mLiveRoomViewHolder.setTitle(data.getTitle()); - //直播间背景 - ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600); - //ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); - mask.setVisibility(View.VISIBLE); - mLivePlayViewHolder.setCover(data.getThumb()); - mLivePlayViewHolder.play(data.getPull()); - mLiveRoomViewHolder.setAvatar(data.getAvatar()); - mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); - mLiveRoomViewHolder.setName(data.getUserNiceName()); - mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); - mLiveRoomViewHolder.setTitle(data.getTitle()); + mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); - mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); + mLiveRoomViewHolder.setLiveUid(data.getUid()); - mLiveRoomViewHolder.setLiveUid(data.getUid()); - - mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this); - if (mLiveLinkMicPresenter != null) { - mLiveLinkMicPresenter.setSocketClient(mSocketClient); + mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this); + if (mLiveLinkMicPresenter != null) { + mLiveLinkMicPresenter.setSocketClient(mSocketClient); + } } //心愿单 LiveHttpUtil.getWishList(mLiveBean.getUid(), new HttpCallback() { @@ -299,8 +304,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } }); enterRoom(); - mLiveRoomViewHolder.initHourRankList(); - mLiveRoomViewHolder.showLiveRoomActivityBanner(); + if(true) { + mLiveRoomViewHolder.initHourRankList(); + mLiveRoomViewHolder.showLiveRoomActivityBanner(); + } } }); @@ -316,43 +323,20 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe IMLoginManager.get(mContext).setisNewUserOne(false); //子线程执行退出操作 exitLiveRoom(); - if (mLiveAudienceViewHolder != null) { - mLiveAudienceViewHolder.removeFromParent(); - mLiveAudienceViewHolder.removeCallbacks(); - mLiveAudienceViewHolder.release(); - } - mLiveAudienceViewHolder = null; + + //断开socket if (mSocketRyClient != null) { mSocketRyClient.disConnect(); + mSocketRyClient = null; } - mSocketRyClient = null; - //结束播放 - if (mLivePlayViewHolder != null) { - mLivePlayViewHolder.removeFromParent(); - mLivePlayViewHolder.stopPlay(); - mLivePlayViewHolder.release(); - } - mLivePlayViewHolder = null; if (mSocketClient != null) { - mSocketClient.disConnect(); mSocketClient = null; } - if (mLiveRoomViewHolder != null) { - mLiveRoomViewHolder.removeFromParent(); - mLiveRoomViewHolder.clearData(); - mLiveRoomViewHolder.countDownTimerTrickery = null; - mLiveRoomViewHolder = null; - } - if (mLiveEndViewHolder != null) { - mLiveEndViewHolder.removeFromParent(); - mLiveEndViewHolder.release(); - mLiveEndViewHolder = null; - } if (mLiveLinkMicPresenter != null) { mLiveLinkMicPresenter.clearData(); mLiveLinkMicPresenter.release(); @@ -367,6 +351,33 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } if (isQuit) { isQuitF = true; + if (mLiveAudienceViewHolder != null) { + mLiveAudienceViewHolder.removeFromParent(); + mLiveAudienceViewHolder.removeCallbacks(); + mLiveAudienceViewHolder.release(); + } + //结束播放 + if (mLivePlayViewHolder != null) { + mLivePlayViewHolder.removeFromParent(); + mLivePlayViewHolder.stopPlay(); + mLivePlayViewHolder.release(); + } + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.removeFromParent(); + mLiveRoomViewHolder.clearData(); + mLiveRoomViewHolder.countDownTimerTrickery = null; + } + if (mLiveEndViewHolder != null) { + mLiveEndViewHolder.removeFromParent(); + mLiveEndViewHolder.release(); + } + mLiveAudienceViewHolder = null; + mLivePlayViewHolder = null; + mLiveRoomViewHolder = null; + mLiveEndViewHolder = null; + mLiveLinkMicPresenter=null; + mLiveLinkMicAnchorPresenter=null; + mLiveRyLinkMicPkPresenter=null; if (PermissionUtils.checkPermission(mContext)) { LiveFloatView.getInstance() .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal) From b5ebc085b4d6b8bcc3fc5e13a230ef71310ca207 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 31 Oct 2022 17:53:09 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E6=88=90=E8=85=BE?= =?UTF-8?q?=E8=AE=AF=E6=92=AD=E6=94=BE=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- live/build.gradle | 2 +- .../live/views/LivePlayRyViewHolder.java | 138 ++++++++++++++---- .../yunbao/live/views/LiveRoomViewHolder.java | 5 + .../live/views/PortraitLiveManager.java | 48 +++--- .../main/res/layout/view_live_play_ksy.xml | 3 +- 5 files changed, 137 insertions(+), 59 deletions(-) diff --git a/live/build.gradle b/live/build.gradle index e76f37fc2..f8dddcdbd 100644 --- a/live/build.gradle +++ b/live/build.gradle @@ -1 +1 @@ -apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" implementation 'com.google.android.exoplayer:exoplayer-core:2.18.1' implementation 'com.google.android.exoplayer:exoplayer-rtsp:2.17.1' implementation 'com.google.android.exoplayer:exoplayer-ui:2.18.1' } \ No newline at end of file +apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" } \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index c18162203..7821d708e 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -18,10 +18,6 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import com.alibaba.fastjson.JSON; -import com.google.android.exoplayer2.ExoPlayer; -import com.google.android.exoplayer2.MediaItem; -import com.google.android.exoplayer2.ui.PlayerView; -import com.google.android.exoplayer2.ui.StyledPlayerView; import com.lzy.okserver.OkDownload; import com.lzy.okserver.download.DownloadTask; import com.tencent.live2.V2TXLiveDef; @@ -82,7 +78,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { private ViewGroup mLeftContainer; private ViewGroup mRightContainer; private RelativeLayout mPkContainer; - public static StyledPlayerView mVideoView; + public static TXCloudVideoView mVideoView; private View mLoading; private ImageView mCover; @@ -94,7 +90,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { private boolean mPausedPlay;//是否被动暂停了播放 public static int landscape; //1h 2s public static Context contexts; - public ExoPlayer mPlayer; + public V2TXLivePlayer mPlayer; public static FrameLayout ry_view; @@ -138,7 +134,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { mLeftContainer = (ViewGroup) findViewById(R.id.left_container); mRightContainer = (ViewGroup) findViewById(R.id.right_container); mPkContainer = (RelativeLayout) findViewById(R.id.pk_container); - mVideoView = (StyledPlayerView) findViewById(R.id.video_view); + mVideoView = (TXCloudVideoView) findViewById(R.id.video_view); ry_view = (FrameLayout) findViewById(R.id.ry_view); leave = (ImageView) findViewById(R.id.leave); mLoading = findViewById(R.id.loading); @@ -150,11 +146,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams(); params.height = vHeight; mPkContainer.requestLayout(); - - mPlayer = new ExoPlayer.Builder(mContext) - .build(); - mVideoView.setPlayer(mPlayer); - + mPlayer = new V2TXLivePlayerImpl(mContext); + mPlayer.setRenderView(mVideoView); } @Override @@ -205,14 +198,103 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { return; } //mPlayer.setCacheParams(1.0f, 5.0f); - if(mPlayer.isPlaying()){ - mPlayer.stop(); - } + mPlayer.setObserver(new V2TXLivePlayerObserver() { + String TAG = "播放流"; + + @Override + public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { + super.onError(player, code, msg, extraInfo); + Log.i(TAG, "onError: player = " + player + ", code = " + code + ", msg = " + msg + ", extraInfo = " + extraInfo); + } + + @Override + public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { + super.onWarning(player, code, msg, extraInfo); + Log.i(TAG, "onWarning: " + "player = " + player + ", code = " + code + ", msg = " + msg + ", extraInfo = " + extraInfo); + if (code == 2105) { + // mPlayer.resumeVideo(); + // mPlayer.resumeAudio(); + mPlayer.stopPlay(); + mPlayer.startPlay(purl); + } + } + + @Override + public void onVideoPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle extraInfo) { + super.onVideoPlayStatusUpdate(player, status, reason, extraInfo); + //Log.i(TAG, "onVideoPlayStatusUpdate: " + "player = " + player + ", status = " + status + ", reason = " + reason + ", extraInfo = " + extraInfo); + } + + @Override + public void onAudioPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle extraInfo) { + super.onAudioPlayStatusUpdate(player, status, reason, extraInfo); + //Log.i(TAG, "onAudioPlayStatusUpdate: " + "player = " + player + ", status = " + status + ", reason = " + reason + ", extraInfo = " + extraInfo); + } + + @Override + public void onPlayoutVolumeUpdate(V2TXLivePlayer player, int volume) { + super.onPlayoutVolumeUpdate(player, volume); + + } + + @Override + public void onStatisticsUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayerStatistics statistics) { + super.onStatisticsUpdate(player, statistics); + Map taskMap = OkDownload.getInstance().getTaskMap(); + StringBuilder buffer = new StringBuilder(); + buffer.append("|"); + for (String key : taskMap.keySet()) { + DownloadTask task = taskMap.get(key); + buffer.append(task.progress.fileName).append(":"); + int status = task.progress.status; + switch (status) { + case 0: + buffer.append("无状态"); + break; + case 1: + buffer.append("等待"); + break; + case 2: + buffer.append("下载中:").append(task.progress.fraction); + break; + case 3: + buffer.append("暂停"); + break; + case 4: + buffer.append("错误"); + break; + case 5: + buffer.append("完成"); + break; + } + buffer.append("|"); + } + //Log.i(TAG, "onStatisticsUpdate: " + JSON.toJSONString(statistics) + " |当前下载数 : " + OkDownload.getInstance().getTaskMap().size() + buffer); + if (statistics.fps == 0) { + OkDownload.getInstance().pauseAll(); + } else { + OkDownload.getInstance().startAll(); + } + } + + @Override + public void onSnapshotComplete(V2TXLivePlayer player, Bitmap image) { + super.onSnapshotComplete(player, image); + } + + @Override + public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveDef.V2TXLiveVideoFrame videoFrame) { + super.onRenderVideoFrame(player, videoFrame); + } + + @Override + public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) { + super.onReceiveSeiMessage(player, payloadType, data); + } + }); + purl = url; - MediaItem item = MediaItem.fromUri(url); - mPlayer.setMediaItem(item); - mPlayer.prepare(); - mPlayer.play(); + mPlayer.startPlay(url); onPrepared(); } @@ -223,8 +305,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { mEnd = true; mStarted = false; if (mPlayer != null) { - mPlayer.stop(); - mPlayer.release(); + mPlayer.stopPlay(); } L.e(TAG, "release------->"); } @@ -238,7 +319,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } } if (mPlayer != null) { - mPlayer.stop(); + mPlayer.stopPlay(); } stopPlay2(); } @@ -427,7 +508,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.topMargin = 0; params.addRule(RelativeLayout.ALIGN_TOP); - // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270); + mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270); mVideoView.requestLayout(); } @@ -437,7 +518,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); params.height = vHeight; params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); - // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0); + mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0); params.addRule(RelativeLayout.ALIGN_TOP); mVideoView.requestLayout(); } @@ -484,11 +565,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { Log.e("ry", "退出多人房间成功"); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { - mPlayer.setMediaItem(MediaItem.fromUri(purl)); + mPlayer.startPlay(purl); Log.e("ry", mPlayer.isPlaying() + "purl" + purl); - if (!mPlayer.isPlaying()) { - mPlayer.prepare(); - mPlayer.play(); + if (mPlayer.isPlaying() != 1) { + mPlayer.startPlay(purl); } ry_view.removeAllViews(); onPrepared(); @@ -550,7 +630,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { for (RCRTCInputStream stream : data.getLiveStreams()) { if (stream.getMediaType() == RCRTCMediaType.VIDEO) { //暂停播放 - mPlayer.stop(); + mPlayer.stopPlay(); //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index e841c0598..0115bd294 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1056,6 +1056,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveChatAdapter.clear(); } } + public void clearGuardIcon(){ + if(userGuard!=null){ + userGuard.setImageResource(R.mipmap.img_guardian_empty); + } + } public synchronized void showStart(StarChallengeStatusModel data) { boolean upData = false; if (mBannerList2 != null && mBannerList2.size() == 0) { diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index fccb40f99..43d4599cf 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -221,7 +221,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe liveBack = mRootContainer.findViewById(R.id.live_back); mask = mRootContainer.findViewById(R.id.mask); } - private static boolean test=true; @Override public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) { openParametersModel = new OpenParametersModel(); @@ -239,8 +238,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe .setParametersModel(openParametersModel .setmLiveType(mLiveType) .setmLiveTypeVal(mLiveTypeVal))); - if (mLivePlayViewHolder == null && test) { - test=false; + if (mLivePlayViewHolder == null) { mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); @@ -253,30 +251,28 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveAudienceViewHolder.addToParent(); mLiveRoomViewHolder.addToParent(); mLiveAudienceViewHolder.subscribeActivityLifeCycle(); - mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this); } - if(true) { - //直播间背景 - ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600); - //ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); - mask.setVisibility(View.VISIBLE); - mLivePlayViewHolder.setCover(data.getThumb()); - mLivePlayViewHolder.play(data.getPull()); - mLiveRoomViewHolder.clearChat(); - mLiveRoomViewHolder.setAvatar(data.getAvatar()); - mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); - mLiveRoomViewHolder.setName(data.getUserNiceName()); - mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); - mLiveRoomViewHolder.setTitle(data.getTitle()); + //直播间背景 + ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600); + //ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); + mask.setVisibility(View.VISIBLE); + mLivePlayViewHolder.setCover(data.getThumb()); + mLivePlayViewHolder.play(data.getPull()); + mLiveRoomViewHolder.clearChat(); + mLiveRoomViewHolder.setAvatar(data.getAvatar()); + mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); + mLiveRoomViewHolder.setName(data.getUserNiceName()); + mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); + mLiveRoomViewHolder.setTitle(data.getTitle()); + mLiveRoomViewHolder.clearGuardIcon(); - mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); + mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); - mLiveRoomViewHolder.setLiveUid(data.getUid()); + mLiveRoomViewHolder.setLiveUid(data.getUid()); - mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this); - if (mLiveLinkMicPresenter != null) { - mLiveLinkMicPresenter.setSocketClient(mSocketClient); - } + mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this); + if (mLiveLinkMicPresenter != null) { + mLiveLinkMicPresenter.setSocketClient(mSocketClient); } //心愿单 LiveHttpUtil.getWishList(mLiveBean.getUid(), new HttpCallback() { @@ -304,10 +300,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } }); enterRoom(); - if(true) { - mLiveRoomViewHolder.initHourRankList(); - mLiveRoomViewHolder.showLiveRoomActivityBanner(); - } + mLiveRoomViewHolder.initHourRankList(); + mLiveRoomViewHolder.showLiveRoomActivityBanner(); } }); diff --git a/live/src/main/res/layout/view_live_play_ksy.xml b/live/src/main/res/layout/view_live_play_ksy.xml index 8302e9bfd..a9d4c4e45 100644 --- a/live/src/main/res/layout/view_live_play_ksy.xml +++ b/live/src/main/res/layout/view_live_play_ksy.xml @@ -8,10 +8,9 @@ > - Date: Mon, 31 Oct 2022 17:53:31 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=87=8D=E5=A4=8D=E5=8F=91=E9=80=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/live/views/LiveAudienceViewHolder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index 046653d28..f8253963d 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -409,6 +409,9 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { handler.postDelayed(runnable = new Runnable() { @Override public void run() { + if(!liveUid.equals(mLiveUid)){ + return; + } if (isattention == 0) { LiveChatBean lvBean = new LiveChatBean(); lvBean.setType(-1); @@ -418,6 +421,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { LiveChatBean lvBean2 = new LiveChatBean(); lvBean2.setType(-2); LiveRoomViewHolder.insertChat(lvBean2, 1); + Log.i("chatMgs", liveUid+"|"+mLiveUid); } }, 10000);//3秒后执行Runnable中的run方法 } From 8d14c062847ce97187669fb9116c13f8af7d17ed Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 1 Nov 2022 11:00:17 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=89=8D=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=92=AD=E6=94=BE=E5=B0=BE=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/yunbao/live/views/LivePlayRyViewHolder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 7821d708e..3528bc106 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -198,6 +198,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { return; } //mPlayer.setCacheParams(1.0f, 5.0f); + mVideoView.clearLastFrame(true); mPlayer.setObserver(new V2TXLivePlayerObserver() { String TAG = "播放流";