Unverified Commit fe7766ad authored by Hampton Maxwell's avatar Hampton Maxwell Committed by GitHub
Browse files

Delay all rate changes until the player unpauses

parent 3e0f084c
Loading
Loading
Loading
Loading
+8 −0
Changes for android/src/main/java/com/brentvatne/react/ReactVideoView.java: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
    private float mVolume = 1.0f;
    private float mProgressUpdateInterval = 250.0f;
    private float mRate = 1.0f;
    private float mActiveRate = 1.0f;
    private boolean mPlayInBackground = false;
    private boolean mActiveStatePauseStatus = false;
    private boolean mActiveStatePauseStatusInitialized = false;
@@ -344,6 +345,10 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
        } else {
            if (!mMediaPlayer.isPlaying()) {
                start();
                // Setting the rate unpauses, so we have to wait for an unpause
                if (mRate != mActiveRate) { 
                    setRateModifier(mRate);
                }

                // Also Start the Progress Update Handler
                mProgressUpdateHandler.post(mProgressUpdateRunnable);
@@ -379,7 +384,10 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP

        if (mMediaPlayerValid) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (!mPaused) { // Applying the rate while paused will cause the video to start
                    mMediaPlayer.setPlaybackParams(mMediaPlayer.getPlaybackParams().setSpeed(rate));
                    mActiveRate = rate;
                }
            } else {
                Log.e(ReactVideoViewManager.REACT_CLASS, "Setting playback rate is not yet supported on Android versions below 6.0");
            }