I am using mediacontroller in my app, but it shows only for 3 seconds. I have searched a lot, but in every document I see only the show function, set time out, but it has no effect. How can I always show mediacontroller?
I have tested show(0)
, but it had no effect.
You can extend the MediaController class and programmatically set an instance of it to a VideoView class:
import android.content.Context;
import android.util.AttributeSet;
import android.widget.MediaController;
public class MyMediaController extends MediaController {
public MyMediaController(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyMediaController(Context context, boolean useFastForward) {
super(context, useFastForward);
}
public MyMediaController(Context context) {
super(context);
}
@Override
public void show(int timeout) {
super.show(0);
}
}
Here's the usage:
VideoView myVideoView = (VideoView) findViewById(R.id.my_video_view);
MediaController mc = new MyMediaController(myVideoView.getContext());
mc.setMediaPlayer(myVideoView);
myVideoView.setMediaController(mc);