android - VideoView CustomControllers Visibility -
i have created custom controllers seekbar on videoview. these controllers in linearlayout , works fine. want set visibility of custom controller layout other android player. when starts video appears 7 second disappears , when user touches video appears , remain 7 secs , touches again disappears. code is
mymusicview.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1) { // todo auto-generated method stub try { if (systemclock.elapsedrealtime() - mlastclicktime < 700){ return false; } mlastclicktime = systemclock.elapsedrealtime(); if(isshowing){ musiccontrollbar.setvisibility(view.gone); isshowing=false; }else{ musiccontrollbar.setvisibility(view.visible); hidelayout(); isshowing=true; } } catch (exception e) { // todo: handle exception } return false; } }); private void hidelayout() { try { musiccontrollbar.setvisibility(view.visible); final handler handler = new handler(); handler.postdelayed(new runnable() { @override public void run() { // todo auto-generated method stub musiccontrollbar.setvisibility(view.invisible); } }, 7000); } catch (exception e) { // todo: handle exception } }
1) first add code mention in above answer private void loadtimer(){ try{ musiccontrolbar.setvisibility(view.visible); countdowntimer = new countdowntimer(7000, 1000){ @override public void ontick(long millisuntilfinished) { //do nothing } @override public void onfinish() { //this hide layout when reach @ 7 sec musiccontrollbar.setvisibility(view.invisible); } }.start(); }catch(exception e){} } 2) try onclicklistener @ videoview in onclick() repeat above code if(isshowing){ musiccontrollbar.setvisibility(view.gone); isshowing=false; }else{ if(countdowntimer!=null){ countdowntimer.cancel(); loadtimer();//start timer } musiccontrollbar.setvisibility(view.visible); isshowing=true; }
Comments
Post a Comment