0

搜索在我的代码中无法正常工作,
我只能在文件的前半部分精确搜索,
我在 {30min, 60min, 90min, 120min} 中使用 mp3 进行了测试并且不工作,但使用 mp4 没关系。

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);


    }

做背景:

    @Override
    protected Integer doInBackground(Integer... params) {       

    prepareFileToPlay();
    mp.start();

    startProgress();

    return null;
}

准备文件:

    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();
    }


}

播放功能:

    public static void play(){
    if(PLAYER != null) PLAYER.cancel(true);
    PLAYER = new Player();

    PLAYER.execute("");
}

寻找功能:

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

}
4

1 回答 1

0

我正在检查我在BlueStacks中的应用程序,但我知道这个问题是专门针对 BlueStacks 的,这不是一个公共问题,它并不重要......

于 2014-04-28T16:38:14.233 回答