android - Stop or cancel the VideoView prepared -
in example having list of video links , next previous buttons. when click on next next video list played. problem when click on next hvideoview.setvideouri(uri.parse(videopath));
called , takes time prepare. in duration if again click on next next video link called. mean while if previous video ready onpreparedlistener()
executed , start older video. want when click on next previous operation should stopped. , here code
public void initializevideo(final string videopath) { baseactivity.showloading(this, "buffering..."); hvideoview.setvisibility(view.visible); lin_webview.setvisibility(view.gone); new handler(looper.mylooper()).post(new runnable(){ @override public void run(){ hvideoview.setvideouri(uri.parse(videopath)); } }); hvideoview.setonpreparedlistener(new onpreparedlistener() { public void onprepared(mediaplayer mp) { mp.setonbufferingupdatelistener(highlightsactivity.this); mp.setoncompletionlistener(highlightsactivity.this); baseactivity.stoploadingdialog(); hvideoview.requestfocus(); hvideoview.start(); mediafilelengthinmilliseconds = hvideoview.getduration(); seek_bar.setmax(mediafilelengthinmilliseconds); primaryseekbarprogressupdater(); imgplay.setvisibility(view.gone); imgpause.setvisibility(view.visible); } }); }
so there way stop onpreparedlistener()
being executed?
in initializevideo
method add before setvideouri
if (hvideoview.isplaying()) { hvideoview.stopplayback(); }
Comments
Post a Comment