audio - Get static time of accomplished method Android -


im working on music player android , need static time start playing music. acutally command context.player.start() take random time range <2;20> [ms] need static time of accomplishing method. code below. mean time difference between "before call method time" , "just after method accomplished time" need static (method should take static time)

public class speakeractivity extends appcompatactivity {       musicplayer player;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_speaker);         player = new musicplayer(speakeractivity.this);         run();     }      private void run() {        asynctask.execute(new runnable() {            @override            public void run() {                clienttask ct = new clienttask(speakeractivity.this);                try {                    ct.run();                } catch (ioexception e1) {                    e1.printstacktrace();                }            }         });     }  }   public class clienttask extends listener {      clienttask(context context) { this.context = context);}      ...       //i'm going implement method listener.class because need use one.     public void received(connection c, object p){         //is received packet same class packetmessage.class?          if(p instanceof packetmessage){              //cast it, can access message within.             packetmessage packet = (packetmessage) p;               if(packet.message.charat(0) == 'p') {                  string latencystring = packet.message.replace('p','0');                 int latency = integer.parseint(latencystring);                 try {                     thread.sleep(latency);                     context.player.start(); <---- line take random amount of time                 } catch (interruptedexception e) {                     e.printstacktrace();                 }                }         }     }   }   public class musicplayer {      private mediaplayer player;     private context context;      public musicplayer(context context) {         this.context = context;         player = mediaplayer.create(context, r.raw.zero);     }      public void start() {         player.start();     }      public void stop() {         player.stop();     }  } 

does know whats wrong?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -