Android:具有可变速度API的视频23

时间:2015-10-26 02:48:46

标签: android android-mediaplayer android-6.0-marshmallow android-video-player

在API 23中添加了PlaybackParams以支持MediaPlayer。

有人对setSpeed中的PlaybackParams方法有什么好运吗?我正在尝试减慢MediaPlayer上的视频并获得100错误(MEDIA_ERROR_SERVER_DIED):

参考文献:

1 个答案:

答案 0 :(得分:1)

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);
            }
        }

    });