0

此代码不起作用,它显示应用程序没有响应。此代码在从远程服务器播放音频时工作正常,但是当我尝试在其上实现搜索栏时,它显示没有响应消息。

songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
    t1x = (TextView) findViewById(R.id.textView1);
    songTotalDurationLabel = (TextView) findViewById(R.id.textView2);
    utils = new Utilities();

    mediaPlayer = new MediaPlayer();
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    try {
        mediaPlayer
                .setDataSource("http://url2.bollywoodmp3.se/murder3/%5BSongs.PK%5D%20Murder%203%20-%2001%20-%20Teri%20Jhuki%20Nazar.mp3");
        mediaPlayer.setOnPreparedListener(this);

        mediaPlayer.prepareAsync();

    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    songProgressBar.setOnSeekBarChangeListener(this); // Important
    songProgressBar.setProgress(0);
    songProgressBar.setMax(100);
    mediaPlayer.setOnCompletionListener(this); // Important
    updateProgressBar();

    // this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

}

@Override
public void onPrepared(MediaPlayer mp) {
    // TODO Auto-generated method stub

    mediaPlayer.start();
}

@Override
protected void onRestart() {
    super.onRestart();
    mediaPlayer.start();
}
4

0 回答 0