App Hangs/Stops Responding When Loading Video Live Streaming Android -
i able watch videos when load video fast. when loading of video long,especially when internet connection slow, stops responding wherein buttons not working @ all, , pressing button not work either. , sometimes, happens when watch video long time e.g. around 25 minutes. got no message on logcat. supposed avoid situation? thank help.
by way, using videoview in playing videos. , minimum targetversion of app 11. below code
public class myclass extends fragment implements oncompletionlistener, onerrorlistener{ @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.movie, container, false); myvideo = (videoview)view.findviewbyid(r.id.myvideo); myvideo.setonerrorlistener(this); myvideo.setoncompletionlistener(this); thread background = new thread(new runnable() { @override public void run() { jsonreturn = helpertool.getvaluefromweb(parse_the_video_link_with_corresponding_video_id); message msgobj = handler.obtainmessage(); handler.sendmessage(msgobj); } @suppresslint("handlerleak") private final handler handler = new handler() { public void handlemessage(message msg) { try { jsonobject jobject = new jsonobject(jsonreturn); id_of_video = jsonobject.getstring("video_id"); the_url_of_video_file = jsonobject.getstring("video_file"); playvideo(the_url_of_video_file); } catch (jsonexception e1) { e1.printstacktrace(); } } }; }); background.start(); return view; } private void playvideo(string url) { uri video = uri.parse(url); myvideo.setvideouri(video); myvideo.setonpreparedlistener(new onpreparedlistener() { @override public void onprepared(mediaplayer mp) { myvideo.start(); } } } @override public void oncompletion(mediaplayer mediaplayer) { log.i("tag", "end"); } @override public void ondestroy() { super.ondestroy(); } @override public boolean onerror(mediaplayer mp, int what, int extra) { if (what == 100){ myvideo.stopplayback(); playvideo(the_url_of_video_file); } return true; } }
i read got no answer. mediaplayer making app not responding
Comments
Post a Comment