fix 重试;

pull/144/head
于俊 9 months ago
parent c30c942e05
commit 660824c33a
  1. 4
      app/src/main/java/com/github/tvbox/osc/player/controller/VodController.java
  2. 14
      app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java
  3. 14
      app/src/main/java/com/github/tvbox/osc/ui/fragment/PlayFragment.java

@ -447,6 +447,7 @@ public class VodController extends BaseController {
updatePlayerCfgView(); updatePlayerCfgView();
listener.updatePlayerCfg(); listener.updatePlayerCfg();
listener.replay(false); listener.replay(false);
listener.setAllowSwitchPlayer(false);
hideBottom(); hideBottom();
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
@ -484,6 +485,7 @@ public class VodController extends BaseController {
updatePlayerCfgView(); updatePlayerCfgView();
listener.updatePlayerCfg(); listener.updatePlayerCfg();
listener.replay(false); listener.replay(false);
listener.setAllowSwitchPlayer(false);
hideBottom(); hideBottom();
} }
} catch (Exception e) { } catch (Exception e) {
@ -784,6 +786,8 @@ public class VodController extends BaseController {
void selectAudioTrack(); void selectAudioTrack();
void startPlayUrl(String url, HashMap<String, String> headers); void startPlayUrl(String url, HashMap<String, String> headers);
void setAllowSwitchPlayer(boolean isAllow);
} }
public void setListener(VodControlListener listener) { public void setListener(VodControlListener listener) {

@ -256,6 +256,8 @@ public class PlayActivity extends BaseActivity {
public void startPlayUrl(String url, HashMap<String, String> headers) { public void startPlayUrl(String url, HashMap<String, String> headers) {
goPlayUrl(url, headers); goPlayUrl(url, headers);
} }
@Override
public void setAllowSwitchPlayer(boolean isAllow){allowSwitchPlayer=isAllow;}
}); });
mVideoView.setVideoController(mController); mVideoView.setVideoController(mController);
} }
@ -873,8 +875,8 @@ public class PlayActivity extends BaseActivity {
} }
private int autoRetryCount = 0; private int autoRetryCount = 0;
private long lastRetryTime = 0; // 记录上次调用时间(毫秒) private long lastRetryTime = 0; // 记录上次调用时间(毫秒)
private boolean allowSwitchPlayer = true;
boolean autoRetry() { boolean autoRetry() {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
@ -882,6 +884,7 @@ public class PlayActivity extends BaseActivity {
if (currentTime - lastRetryTime > 60_000) { if (currentTime - lastRetryTime > 60_000) {
LOG.i("echo-reset-autoRetryCount"); LOG.i("echo-reset-autoRetryCount");
autoRetryCount = 0; autoRetryCount = 0;
allowSwitchPlayer = false;
} }
lastRetryTime = currentTime; // 更新上次调用时间 lastRetryTime = currentTime; // 更新上次调用时间
if (loadFoundVideoUrls != null && !loadFoundVideoUrls.isEmpty()) { if (loadFoundVideoUrls != null && !loadFoundVideoUrls.isEmpty()) {
@ -897,8 +900,13 @@ public class PlayActivity extends BaseActivity {
}else { }else {
//第一次重试直接带着原地址继续播放 //第一次重试直接带着原地址继续播放
if(webPlayUrl!=null){ if(webPlayUrl!=null){
//切换播放器不占用重试次数 if(allowSwitchPlayer){
if(mController.switchPlayer())autoRetryCount++; //切换播放器不占用重试次数
if(mController.switchPlayer())autoRetryCount++;
}else {
autoRetryCount++;
allowSwitchPlayer=true;
}
stopParse(); stopParse();
initParseLoadFound(); initParseLoadFound();
if(mVideoView!=null) mVideoView.release(); if(mVideoView!=null) mVideoView.release();

@ -274,6 +274,8 @@ public class PlayFragment extends BaseLazyFragment {
public void startPlayUrl(String url, HashMap<String, String> headers) { public void startPlayUrl(String url, HashMap<String, String> headers) {
goPlayUrl(url, headers); goPlayUrl(url, headers);
} }
@Override
public void setAllowSwitchPlayer(boolean isAllow){allowSwitchPlayer=isAllow;}
}); });
mVideoView.setVideoController(mController); mVideoView.setVideoController(mController);
} }
@ -905,11 +907,14 @@ public class PlayFragment extends BaseLazyFragment {
private int autoRetryCount = 0; private int autoRetryCount = 0;
private long lastRetryTime = 0; // 记录上次调用时间(毫秒) private long lastRetryTime = 0; // 记录上次调用时间(毫秒)
private boolean allowSwitchPlayer = true;
boolean autoRetry() { boolean autoRetry() {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
if (currentTime - lastRetryTime > 60_000){ if (currentTime - lastRetryTime > 60_000){
LOG.i("echo-reset-autoRetryCount"); LOG.i("echo-reset-autoRetryCount");
autoRetryCount = 0; autoRetryCount = 0;
allowSwitchPlayer = false;
} }
lastRetryTime = currentTime; // 更新上次调用时间 lastRetryTime = currentTime; // 更新上次调用时间
@ -925,8 +930,13 @@ public class PlayFragment extends BaseLazyFragment {
}else { }else {
//第一次重试直接带着原地址继续播放 //第一次重试直接带着原地址继续播放
if(webPlayUrl!=null){ if(webPlayUrl!=null){
//切换播放器不占用重试次数 if(allowSwitchPlayer){
if(mController.switchPlayer())autoRetryCount++; //切换播放器不占用重试次数
if(mController.switchPlayer())autoRetryCount++;
}else {
autoRetryCount++;
allowSwitchPlayer=true;
}
stopParse(); stopParse();
initParseLoadFound(); initParseLoadFound();
if(mVideoView!=null) mVideoView.release(); if(mVideoView!=null) mVideoView.release();

Loading…
Cancel
Save