@Override public void onStateChanged(boolean playWhenReady, int playbackState) { if (lytter == null) return; switch (playbackState) { case ExoPlayer.STATE_BUFFERING: lytter.onBufferingUpdate(null, player.getBufferedPercentage()); break; case ExoPlayer.STATE_ENDED: lytter.onCompletion(null); break; case ExoPlayer.STATE_IDLE: lytter.onCompletion(null); // text += "idle"; break; case ExoPlayer.STATE_PREPARING: lytter.onBufferingUpdate(null, 100); break; case ExoPlayer.STATE_READY: lytter.onPrepared(null); break; default: break; } }
@Override public int getCurrentPosition() { return (int) player.getCurrentPosition(); }
@Override public int getDuration() { if (player == null) return 0; // fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/3038148734 return (int) player.getDuration(); }
@Override public void seekTo(int offsetMs) { if (player != null) player.seekTo(offsetMs); }
@Override public boolean isPlaying() { return player != null && player.getPlaybackState() == ExoPlayer.STATE_READY; }
@Override public void release() { player.release(); }
@Override public void stop() { if (player != null) player.getPlayerControl().pause(); stayAwake(false); }
@Override public void start() { player.getPlayerControl().start(); stayAwake(true); }