pull/586/head
FongMi 2 years ago
parent e2931cece7
commit e82d03276e
  1. 15
      app/src/main/java/com/fongmi/android/tv/player/Players.java

@ -67,7 +67,6 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac
private ParseJob parseJob; private ParseJob parseJob;
private Runnable runnable; private Runnable runnable;
private ExoPlayer player; private ExoPlayer player;
private List<Sub> subs;
private String format; private String format;
private String url; private String url;
private Sub sub; private Sub sub;
@ -78,7 +77,6 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac
private int retry; private int retry;
public Players init(Activity activity) { public Players init(Activity activity) {
subs = new ArrayList<>();
decode = Setting.getDecode(); decode = Setting.getDecode();
builder = new StringBuilder(); builder = new StringBuilder();
runnable = ErrorEvent::timeout; runnable = ErrorEvent::timeout;
@ -146,7 +144,6 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac
public void clear() { public void clear() {
headers = null; headers = null;
format = null; format = null;
subs = null;
url = null; url = null;
} }
@ -366,7 +363,7 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac
} }
private List<Sub> checkSub(List<Sub> subs) { private List<Sub> checkSub(List<Sub> subs) {
if (sub == null || subs.contains(sub)) return subs; if (sub == null) return subs;
subs.add(0, sub); subs.add(0, sub);
return subs; return subs;
} }
@ -376,23 +373,23 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac
} }
private void setMediaSource(Map<String, String> headers, String url) { private void setMediaSource(Map<String, String> headers, String url) {
setMediaSource(checkUa(headers), url, null, null, checkSub(subs), Constant.TIMEOUT_PLAY); setMediaSource(headers, url, null, null, new ArrayList<>(), Constant.TIMEOUT_PLAY);
} }
private void setMediaSource(Map<String, String> headers, String url, String format) { private void setMediaSource(Map<String, String> headers, String url, String format) {
setMediaSource(checkUa(headers), url, format, null, checkSub(subs), Constant.TIMEOUT_PLAY); setMediaSource(headers, url, format, null, new ArrayList<>(), Constant.TIMEOUT_PLAY);
} }
private void setMediaSource(Channel channel, int timeout) { private void setMediaSource(Channel channel, int timeout) {
setMediaSource(checkUa(channel.getHeaders()), channel.getUrl(), channel.getFormat(), channel.getDrm(), checkSub(subs), timeout); setMediaSource(channel.getHeaders(), channel.getUrl(), channel.getFormat(), channel.getDrm(), new ArrayList<>(), timeout);
} }
private void setMediaSource(Result result, int timeout) { private void setMediaSource(Result result, int timeout) {
setMediaSource(checkUa(result.getHeaders()), result.getRealUrl(), result.getFormat(), result.getDrm(), checkSub(result.getSubs()), timeout); setMediaSource(result.getHeaders(), result.getRealUrl(), result.getFormat(), result.getDrm(), checkSub(result.getSubs()), timeout);
} }
private void setMediaSource(Map<String, String> headers, String url, String format, Drm drm, List<Sub> subs, int timeout) { private void setMediaSource(Map<String, String> headers, String url, String format, Drm drm, List<Sub> subs, int timeout) {
if (player != null) player.setMediaSource(ExoUtil.getSource(this.headers = headers, this.url = url, ExoUtil.getMimeType(this.format = format, error), drm, this.subs = subs, decode), position); if (player != null) player.setMediaSource(ExoUtil.getSource(this.headers = checkUa(headers), this.url = url, ExoUtil.getMimeType(this.format = format, error), drm, checkSub(subs), decode), position);
if (player != null) player.prepare(); if (player != null) player.prepare();
Logger.t(TAG).d(error + "," + url); Logger.t(TAG).d(error + "," + url);
App.post(runnable, timeout); App.post(runnable, timeout);

Loading…
Cancel
Save