getCurrentPosition() for mediaplayer in android studio not works -


i'm programming media player android studio. want use getcurrentposition show time of music in each second give me 0. should do?

public class playandpause extends service { mediaplayer mp; @override public void oncreate() {     super.oncreate();     mp=mediaplayer.create(this, r.raw.s); }  @override public void onstart(intent intent, int startid) {     super.onstart(intent, startid);     if(mainactivity.a==1) {         mp.start();         toast.maketext(this, "music started!", toast.length_short).show();     }     if(mainactivity.a==2) {         mp.pause();         toast.maketext(this, "music paused!", toast.length_short).show();     }     integer k=mp.getcurrentposition();     log.i("+++++++", k.tostring());  }  @override public void ondestroy() {     super.ondestroy();     mp.stop();     toast.maketext(this, "music stopped!", toast.length_short).show(); }  @override public ibinder onbind(intent intent) {     // todo: return communication channel service.     throw new unsupportedoperationexception("not yet implemented"); } 

}

and log gives me 0 every 1 second.any idea?


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -