Example usage for android.media MediaPlayer getPlaybackParams

List of usage examples for android.media MediaPlayer getPlaybackParams

Introduction

In this page you can find the example usage for android.media MediaPlayer getPlaybackParams.

Prototype

@NonNull
public native PlaybackParams getPlaybackParams();

Source Link

Document

Gets the playback params, containing the current playback rate.

Usage

From source file:github.popeen.dsub.service.DownloadService.java

private synchronized void applyPlaybackParams(MediaPlayer mediaPlayer) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        float playbackSpeed = getPlaybackSpeed();

        try {//from w  ww . j  a va  2 s .  c om
            if (Math.abs(playbackSpeed - 1.0) > 0.01 || mediaPlayer.getPlaybackParams() != null) {
                PlaybackParams playbackParams = new PlaybackParams();
                playbackParams.setSpeed(playbackSpeed);
                mediaPlayer.setPlaybackParams(playbackParams);
            }
        } catch (Exception e) {
            Log.e(TAG, "Error while applying media player params", e);
        }
    }
}