android - Can't seek mp3 more than 50% with MediaPlayer in AsyncTask -
seeking not work correctly in code,
can seek in first half of files,
tested mp3 in {30min, 60min, 90min, 120min} , don't work, mp4 it's ok.
public class player extends asynctask<integer, integer, integer> implements onbufferingupdatelistener, oncompletionlistener, onerrorlistener { private static mediaplayer mp; protected static player player = null; public player(){ mp = defined.mp; mp.setonbufferingupdatelistener(this); mp.setoncompletionlistener(this); mp.setonerrorlistener(this); }
doinbackground:
@override protected integer doinbackground(integer... params) { preparefiletoplay(); mp.start(); startprogress(); return null; }
prepare file:
protected void preparefiletoplay(){ string url="http://192.168.1.2/test10.mp3"; //mp3 duration: 60min mp.reset(); try { mp.setdatasource(url); mp.prepare(); publishprogress(playing); } catch (illegalargumentexception e) { e.printstacktrace(); } catch (securityexception e) { e.printstacktrace(); } catch (illegalstateexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } }
play function:
public static void play(){ if(player != null) player.cancel(true); player = new player(); player.execute(""); }
seek function:
public static void seekto(int time){ //mp.seekto(time); //mp.seekto(mp.getduration()-10000); //seekto 59:50 //mp.seekto(mp.getduration()-60000); //seekto 59:00 log.v("player", "currentposition: "+ mp.getcurrentposition() + " duration:"+ mp.getduration()); //duration: 60 min }
i checking application in bluestacks, understand issue dedicated bluestacks , not public issue , it's not important...
Comments
Post a Comment