Question

seeking is not work correctly in my code,
I can only seek exactly in first half of my files,
I tested with mp3 in {30min, 60min, 90min, 120min} and don't work, but with 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

}
Was it helpful?

Solution

I was checking my application in BlueStacks, but I understand that this issue is dedicated to BlueStacks and this is not a public issue and it's not important...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top