Control the playback speed of video in android

后端 未结 3 1535
星月不相逢
星月不相逢 2020-12-19 07:20

I am using a VideoView to play a video file kept in res/raw. I couldnt find a way to control the playback speed of the video. Basically i want to reduce and increase the pla

3条回答
  •  一整个雨季
    2020-12-19 07:27

    you can use this but it works on api 23 and above

     mVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
    
                //works only from api 23
                PlaybackParams myPlayBackParams = null;
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                    myPlayBackParams = new PlaybackParams();
                    myPlayBackParams.setSpeed(0.8f); //you can set speed here
                    mp.setPlaybackParams(myPlayBackParams);
                }
    
            }
        });
    

提交回复
热议问题