There are two main issues with MediaController:
- auto hide - default 3s
- Clicking on the video shows / hides the control panel
In the first part, it easily captures the change in the default timeout value for starting to zero (zero means indefinite, it is used internally when starting a video) as follows:
mediaController = new MediaController(this){ @Override public void show() { super.show(0);
The second problem is a bit complicated because the click handler is declared closed and final, so we have no control over this. My solution is to use another function to determine the visibility and disable the hide function as follows:
mediaController = new MediaController(this){ @Override public void show() { super.show(0);//Default no auto hide timeout } @Override public void hide() { //DOES NOTHING } void setVisible(boolean visible){//USE THIS FUNCTION INSTEAD if(visible) super.show(); else super.hide(); } };
You can also add a variable to re-enable standard functions if visibility is set to false:
mediaController = new MediaController(this){ private boolean forceVisible=false; @Override public void show() { super.show(0);//Default no auto hide timeout } @Override public void hide() { if(!forceVisible)super.hide(); } void setVisible(boolean visible){ forceVisible=visible; if(visible) super.show(); else super.hide(); } };
source share