From 3e0f084c621e7af0a60a13c701cb94cd3b211041 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik Date: Wed, 27 Sep 2017 16:13:29 +0100 Subject: [PATCH] Implement 'rate' prop for android devices - Version locked to 6.0+ because that is the version that introduced setPlaybackParams - Ignores rate prop as before on android versions lower than 6.0 --- .../main/java/com/brentvatne/react/ReactVideoView.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoView.java b/android/src/main/java/com/brentvatne/react/ReactVideoView.java index 94a25a0e..099bec33 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -5,6 +5,7 @@ import android.content.res.AssetFileDescriptor; import android.graphics.Matrix; import android.media.MediaPlayer; import android.net.Uri; +import android.os.Build; import android.os.Handler; import android.util.Log; import android.view.MotionEvent; @@ -377,8 +378,11 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP mRate = rate; if (mMediaPlayerValid) { - // TODO: Implement this. - Log.e(ReactVideoViewManager.REACT_CLASS, "Setting playback rate is not yet supported on Android"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + mMediaPlayer.setPlaybackParams(mMediaPlayer.getPlaybackParams().setSpeed(rate)); + } else { + Log.e(ReactVideoViewManager.REACT_CLASS, "Setting playback rate is not yet supported on Android versions below 6.0"); + } } } @@ -388,7 +392,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP setPausedModifier(mPaused); setMutedModifier(mMuted); setProgressUpdateInterval(mProgressUpdateInterval); -// setRateModifier(mRate); + setRateModifier(mRate); } public void setPlayInBackground(final boolean playInBackground) {