java - How to get elements from Linked list using get method -
i developing radio streaming application in android , have url in linked list parsed content .pls file link , needed parse content url need elements linked list using get(position) method.can have suggestions here need help.
here code snippet ,i want use url linked list player=mediaplayer.create(this,uri.parse("//url linked list"));
i have parsed url .pls file link in linked list , need elements linked list linked list object
linkedlist<string> urls; private linkedlist<string> fgetplayableurl( string mpls) { getstreamingurl ogetstreamingurl = new getstreamingurl(mainactivity.this); urls=new linkedlist<string>(); urls = ogetstreamingurl.getstreamingurl(mpls); return urls; } private void initializemediaplayer() throws ioexception { player = new mediaplayer(); //int ; /* (i=0;i<='\0';i++) { }*/ //url=urls.get(2).tostring(); try { player=mediaplayer.create(this,uri.parse("//url here")); player.setdatasource(url); //player.prepareasync(); //player.start(); } catch (illegalargumentexception e) { e.printstacktrace(); } catch (illegalstateexception e) { e.printstacktrace(); } player.setonbufferingupdatelistener(new onbufferingupdatelistener() { public void onbufferingupdate(mediaplayer mp, int percent) { playseekbar.setsecondaryprogress(percent); log.i("buffering", "" + percent); } }); }
why dont try put player=mediaplayer.create(this,uri.parse("//url here"));
inside loop of link list this:
linkedlist<string> urls; // make method void. //anyways linkedlist still accessible globally //and instantiating linkedlist inside method; private void fgetplayableurl( string mpls) { getstreamingurl ogetstreamingurl = new getstreamingurl(mainactivity.this); urls=new linkedlist<string>(); urls = ogetstreamingurl.getstreamingurl(mpls); } private void initializemediaplayer() throws ioexception { player = new mediaplayer(); //int ; /* (i=0;i<='\0';i++) { }*/ //url=urls.get(2).tostring(); fgetplayableurl(url string here); for(string url:urls){ try { player=mediaplayer.create(this,uri.parse(url)); player.setdatasource(url); //player.prepareasync(); //player.start(); } catch (illegalargumentexception e) { e.printstacktrace(); } catch (illegalstateexception e) { e.printstacktrace(); } player.setonbufferingupdatelistener(new onbufferingupdatelistener() { public void onbufferingupdate(mediaplayer mp, int percent) { playseekbar.setsecondaryprogress(percent); log.i("buffering", "" + percent); } }); } }
Comments
Post a Comment