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
This commit is contained in:
Louis Capitanchik
2017-09-27 16:13:29 +01:00
parent f73b7a0484
commit 3e0f084c62

View File

@@ -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) {