Merge pull request #3664 from spacecowboy/speedwhilepaused

Added playback params to wrapper so speed can be changed while paused
This commit is contained in:
H. Lehmann 2019-12-01 23:01:42 +01:00 committed by GitHub
commit ed6e4d6206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -46,11 +46,13 @@ public class ExoPlayerWrapper implements IPlayer {
private MediaPlayer.OnCompletionListener audioCompletionListener;
private MediaPlayer.OnErrorListener audioErrorListener;
private MediaPlayer.OnBufferingUpdateListener bufferingUpdateListener;
private PlaybackParameters playbackParameters;
ExoPlayerWrapper(Context context) {
mContext = context;
mExoPlayer = createPlayer();
playbackParameters = mExoPlayer.getPlaybackParameters();
bufferingUpdateDisposable = Observable.interval(2, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
@ -145,7 +147,7 @@ public class ExoPlayerWrapper implements IPlayer {
@Override
public float getCurrentSpeedMultiplier() {
return mExoPlayer.getPlaybackParameters().speed;
return playbackParameters.speed;
}
@Override
@ -225,8 +227,8 @@ public class ExoPlayerWrapper implements IPlayer {
@Override
public void setPlaybackParams(float speed, boolean skipSilence) {
PlaybackParameters params = mExoPlayer.getPlaybackParameters();
mExoPlayer.setPlaybackParameters(new PlaybackParameters(speed, params.pitch, skipSilence));
playbackParameters = new PlaybackParameters(speed, playbackParameters.pitch, skipSilence);
mExoPlayer.setPlaybackParameters(playbackParameters);
}
@Override
@ -247,6 +249,8 @@ public class ExoPlayerWrapper implements IPlayer {
@Override
public void start() {
mExoPlayer.setPlayWhenReady(true);
// Can't set params when paused - so always set it on start in case they changed
mExoPlayer.setPlaybackParameters(playbackParameters);
}
@Override