Control the playback speed of video in android

2019-01-26 13:03发布

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 playback while moving a scroll bar. Is there any work around for implementing this?

3条回答
Root(大扎)
2楼-- · 2019-01-26 13:41

No, you cannot change the playback rate by simply using VideoView. VideoView and MediaPlayer only provide limited media functions.

You have to use some third party library, e.g., PVPlayer, and implement that yourself.

That's also why good media players on Android are so valuable:)

查看更多
甜甜的少女心
3楼-- · 2019-01-26 13:45

DicePlayer works perfectly on my Asus Transformer. It has a speed control onscreen display.

I'm not sure what res/raw is though.

查看更多
Fickle 薄情
4楼-- · 2019-01-26 13:52

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

        }
    });
查看更多
登录 后发表回答