fix 重试;

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

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

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

Loading…
Cancel
Save