Android_programmer_camera
Android_programmer_camera

Reputation: 13369

Media controls Bar disappears after appearing for a second in VideoView Android

I am able to play a video using VideoView in combination with MediaController. The problem when I started my activity , a bar appears below with media controllers play,pause,rewind ,progress bar representing video. But it disappears after displaying 1 second. Then I how can I make this media Controller bar with controls to display as long as my video plays so that I can pause,rewind my video.

Thanks in Advance

Upvotes: 2

Views: 2348

Answers (2)

Harsh Patel
Harsh Patel

Reputation: 101

The problem is that MediaController class has default timeout of 3000ms or 3seconds. And its show() method replaces our given parameter to its default parameter. Its a stupid bug resulting from untested code at Google.

We need to implement a lousy workaround of replacing the default value by desired value.

Try this:

mediaControls = new MediaController(getActivity()){
            @Override
            public void show (int timeout){
                if(timeout == 3000) timeout = 20000; //Set to desired number
                super.show(timeout);
            }
        };
mVideoView.setMediaController(mediaControls);

Upvotes: 3

CommonsWare
CommonsWare

Reputation: 1007099

Try calling show(0) on the MediaController.

Upvotes: 0

Related Questions