修复滑动直播间到同一个主播时,会黑屏的问题

This commit is contained in:
zlzw 2023-01-14 13:19:23 +08:00
parent 16592aaecb
commit 1bbab7ac9e
2 changed files with 8 additions and 2 deletions

View File

@ -40,9 +40,9 @@ public class LiveExoPlayerManager {
public LiveExoPlayerManager(Context mContext) { public LiveExoPlayerManager(Context mContext) {
DefaultLoadControl control = new DefaultLoadControl.Builder() DefaultLoadControl control = new DefaultLoadControl.Builder()
.setPrioritizeTimeOverSizeThresholds(false) .setPrioritizeTimeOverSizeThresholds(false)
.setBackBuffer(120_000, true) .setBackBuffer(10_000, true)
.setBufferDurationsMs(500, .setBufferDurationsMs(500,
60_000, 5_000,
150, 150,
200) 200)
.build(); .build();
@ -328,6 +328,7 @@ public class LiveExoPlayerManager {
*/ */
public void stop() { public void stop() {
getNowPlayer().stop(); getNowPlayer().stop();
clearUrl();
} }
/** /**
@ -355,9 +356,13 @@ public class LiveExoPlayerManager {
* 释放播放器 * 释放播放器
*/ */
public void release() { public void release() {
Log.i(TAG, "release: 释放播放器");
player1.release(); player1.release();
player2.release(); player2.release();
} }
public void clearUrl(){
url="";
}
public String getUrl() { public String getUrl() {
if (url == null) { if (url == null) {

View File

@ -302,6 +302,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
if (mPlayer.isPlaying()) { if (mPlayer.isPlaying()) {
mPlayer.stop(); mPlayer.stop();
mPlayer.clearUrl();
} }
mPlayer.startUrl(url); mPlayer.startUrl(url);
purl = url; purl = url;