Support live timeout

pull/137/head
FongMi 3 years ago
parent fc7995072e
commit 4d41e7aae7
  1. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  2. 7
      app/src/main/java/com/fongmi/android/tv/bean/Live.java
  3. 2
      app/src/main/java/com/fongmi/android/tv/bean/Site.java
  4. 5
      app/src/main/java/com/fongmi/android/tv/player/Players.java
  5. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java

@ -213,7 +213,7 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
private void setViewModel() {
mViewModel = new ViewModelProvider(this).get(LiveViewModel.class);
mViewModel.channel.observe(this, result -> mPlayers.start(result));
mViewModel.channel.observe(this, result -> mPlayers.start(result, getHome().getTimeout()));
mViewModel.live.observe(this, live -> {
hideProgress();
setGroup(live);

@ -3,6 +3,7 @@ package com.fongmi.android.tv.bean;
import android.net.Uri;
import android.text.TextUtils;
import com.fongmi.android.tv.Constant;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.annotations.SerializedName;
@ -36,6 +37,8 @@ public class Live {
private String ua;
@SerializedName("referer")
private String referer;
@SerializedName("timeout")
private Integer timeout;
@SerializedName("header")
private JsonElement header;
@SerializedName("playerType")
@ -112,6 +115,10 @@ public class Live {
return TextUtils.isEmpty(referer) ? "" : referer;
}
public Integer getTimeout() {
return timeout == null ? Constant.TIMEOUT_PLAY : Math.max(timeout, 1) * 1000;
}
public JsonElement getHeader() {
return header;
}

@ -114,7 +114,7 @@ public class Site {
}
public Integer getTimeout() {
return timeout == null ? Constant.TIMEOUT_PLAY : timeout;
return timeout == null ? Constant.TIMEOUT_PLAY : Math.max(timeout, 1) * 1000;
}
public int getPlayerType() {

@ -11,7 +11,6 @@ import androidx.media3.exoplayer.analytics.AnalyticsListener;
import androidx.media3.ui.PlayerView;
import com.fongmi.android.tv.App;
import com.fongmi.android.tv.Constant;
import com.fongmi.android.tv.R;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.bean.Channel;
@ -74,7 +73,6 @@ public class Players implements Player.Listener, IMediaPlayer.Listener, Analytic
decode = Setting.getDecode();
builder = new StringBuilder();
runnable = ErrorEvent::timeout;
timeout = Constant.TIMEOUT_PLAY;
formatter = new Formatter(builder, Locale.getDefault());
return this;
}
@ -292,10 +290,11 @@ public class Players implements Player.Listener, IMediaPlayer.Listener, Analytic
}
}
public void start(Channel channel) {
public void start(Channel channel, int timeout) {
if (channel.getUrl().isEmpty()) {
ErrorEvent.url();
} else {
this.timeout = timeout;
setMediaSource(channel);
}
}

@ -215,7 +215,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
private void setViewModel() {
mViewModel = new ViewModelProvider(this).get(LiveViewModel.class);
mViewModel.channel.observe(this, result -> mPlayers.start(result));
mViewModel.channel.observe(this, result -> mPlayers.start(result, getHome().getTimeout()));
mViewModel.live.observe(this, live -> {
hideProgress();
setGroup(live);

Loading…
Cancel
Save