John Shelley
John Shelley

Reputation: 2655

Android: Video with variable speed API 23

In API 23 PlaybackParams have been added for MediaPlayer support.

Has anyone had any luck with the setSpeed method in PlaybackParams? I'm trying to slow down video on MediaPlayer and getting a 100 error (MEDIA_ERROR_SERVER_DIED):

References:

Upvotes: 1

Views: 1557

Answers (1)

user2306482
user2306482

Reputation: 121

mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            //Log.d(TAG, "onPrepared Start: " + mPlaybackState + " LeanbackPlaybackState:" + LeanbackPlaybackState.PLAYING );
            if (mPlaybackState == LeanbackPlaybackState.FastForward) {
               mp.setPlaybackParams(new PlaybackParams().setSpeed(3.0f));
                mVideoView.start();
                Log.d(TAG, "onPrepared: if " + mPlaybackState + " LeanbackPlaybackState:" + LeanbackPlaybackState.FastForward);
            }
            else  
            if  (mPlaybackState == LeanbackPlaybackState.PLAYING){
                mp.setPlaybackParams(new PlaybackParams().setSpeed(1.0f));
                mVideoView.start();
                Log.d(TAG, "onPrepared: else " + mPlaybackState + " LeanbackPlaybackState:" +LeanbackPlaybackState.PLAYING);
            }
        }

    });

Upvotes: 1

Related Questions