Android Media Player Next Song -
i have listview in mainactivity hehe passing listview position using this
intent intent = new intent(mainactivity.this, linkview.class); intent.putextra("position", position); startactivity(intent);
and have linkview class here received position using this
final bundle bundle = getintent().getextras(); position = bundle.getint("position");
and have linkarray list.
link = getresources().getstringarray(r.array.lin
my player play , can stop it. have next button
next.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { uri = uri.parse(link[position+1]); } });
when pressed next button nil happened. want when pressed next button array
next link play nil play. how can solve issue.
my hole code here.
public class linkview extends activity { button play, stop, next; mediaplayer mediaplayer; private string currentsongindex; rowitem rowitem; mainactivity mainactivity; uri uri; public string link[]; int position; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, 0); setcontentview(r.layout.activity_linkview); stop = (button) findviewbyid(r.id.stopbutton); play = (button) findviewbyid(r.id.playbutton); next = (button) findviewbyid(r.id.nextbutton1); link = getresources().getstringarray(r.array.link); // string itemstring = mainactivity.link[position]; final bundle bundle = getintent().getextras(); // string link = bundle.getstring("link"); // position = bundle.getint("position"); next.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { mediaplayer.stop(); if (position <= 2) { uri = uri.parse(link[position + 1]); } } }); position = bundle.getint("position"); uri = uri.parse(link[position]); // .parse("android.resource://com.prgguru.example/" // + r.raw.hosannatamil);"); mediaplayer = new mediaplayer(); mediaplayer.setaudiostreamtype(audiomanager.stream_music); seek { mediaplayer.setdatasource(getapplicationcontext(), uri); } grab (illegalargumentexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (securityexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (illegalstateexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } seek { mediaplayer.prepare(); } grab (illegalstateexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } mediaplayer.start(); stop.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub if (mediaplayer != null && mediaplayer.isplaying()) { mediaplayer.stop(); } } }); play.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub // todo auto-generated method stub seek { mediaplayer.prepare(); } grab (illegalstateexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } mediaplayer.start(); } }); } protected void ondestroy() { super.ondestroy(); // todo auto-generated method stub if (mediaplayer != null) { mediaplayer.release(); mediaplayer = null; } } }
maybe work:
next.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { mediaplayer.stop(); uri = uri.parse(link[position + 1]); mediaplayer.setdatasource(getapplicationcontext(), uri); mediaplayer.prepare(); mediaplayer.start(); } });
android android-listview
No comments:
Post a Comment