|
|
|
|
@ -74,18 +74,18 @@ public class Players implements Player.Listener, ParseTask.Callback { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getSpeed() { |
|
|
|
|
return String.format(Locale.getDefault(), "%.2f", exoPlayer.getPlaybackParameters().speed); |
|
|
|
|
return String.format(Locale.getDefault(), "%.2f", exo().getPlaybackParameters().speed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addSpeed() { |
|
|
|
|
float speed = exoPlayer.getPlaybackParameters().speed; |
|
|
|
|
float speed = exo().getPlaybackParameters().speed; |
|
|
|
|
float addon = speed >= 2 ? 1f : 0.25f; |
|
|
|
|
speed = speed >= 5 ? 0.5f : speed + addon; |
|
|
|
|
exoPlayer.setPlaybackSpeed(speed); |
|
|
|
|
exo().setPlaybackSpeed(speed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void resetSpeed() { |
|
|
|
|
exoPlayer.setPlaybackSpeed(1f); |
|
|
|
|
exo().setPlaybackSpeed(1f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getTime(long time) { |
|
|
|
|
@ -100,27 +100,27 @@ public class Players implements Player.Listener, ParseTask.Callback { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public long getCurrentPosition() { |
|
|
|
|
return exoPlayer.getCurrentPosition(); |
|
|
|
|
return exo().getCurrentPosition(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public long getDuration() { |
|
|
|
|
return exoPlayer.getDuration(); |
|
|
|
|
return exo().getDuration(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void seekTo(int time) { |
|
|
|
|
exoPlayer.seekTo(getCurrentPosition() + time); |
|
|
|
|
exo().seekTo(getCurrentPosition() + time); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void seekTo(long time) { |
|
|
|
|
exoPlayer.seekTo(time); |
|
|
|
|
exo().seekTo(time); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isPlaying() { |
|
|
|
|
return exoPlayer.isPlaying(); |
|
|
|
|
return exo().isPlaying(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isIdle() { |
|
|
|
|
return exoPlayer.getPlaybackState() == Player.STATE_IDLE; |
|
|
|
|
return exo().getPlaybackState() == Player.STATE_IDLE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean canNext() { |
|
|
|
|
@ -139,39 +139,31 @@ public class Players implements Player.Listener, ParseTask.Callback { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setMediaSource(Result result) { |
|
|
|
|
exoPlayer.setMediaSource(ExoUtil.getSource(result)); |
|
|
|
|
exo().setMediaSource(ExoUtil.getSource(result)); |
|
|
|
|
PlayerEvent.state(0); |
|
|
|
|
exoPlayer.prepare(); |
|
|
|
|
exo().prepare(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setMediaSource(Map<String, String> headers, String url) { |
|
|
|
|
exoPlayer.setMediaSource(ExoUtil.getSource(headers, url)); |
|
|
|
|
exo().setMediaSource(ExoUtil.getSource(headers, url)); |
|
|
|
|
PlayerEvent.state(0); |
|
|
|
|
exoPlayer.prepare(); |
|
|
|
|
exo().prepare(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void pause() { |
|
|
|
|
if (exoPlayer != null) { |
|
|
|
|
exoPlayer.pause(); |
|
|
|
|
} |
|
|
|
|
exo().pause(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void stop() { |
|
|
|
|
this.retry = 0; |
|
|
|
|
if (exoPlayer != null) { |
|
|
|
|
exoPlayer.stop(); |
|
|
|
|
exoPlayer.clearMediaItems(); |
|
|
|
|
exoPlayer.setPlaybackSpeed(1.0f); |
|
|
|
|
} |
|
|
|
|
if (webView != null) { |
|
|
|
|
webView.stop(false); |
|
|
|
|
} |
|
|
|
|
exo().stop(); |
|
|
|
|
exo().clearMediaItems(); |
|
|
|
|
exo().setPlaybackSpeed(1.0f); |
|
|
|
|
if (webView != null) webView.stop(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void play() { |
|
|
|
|
if (exoPlayer != null) { |
|
|
|
|
exoPlayer.play(); |
|
|
|
|
} |
|
|
|
|
exo().play(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void release() { |
|
|
|
|
|