结果是前两首歌曲播放得很好,但其他歌曲没有播放,几乎没有播放到最后一首歌曲!
播放流的代码(有效):
private void PlayStream(String url)
{
try
{
mediaPlayer.setDataSource(url);
}
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();
}
mediaPlayer.setOnPreparedListener(Canzone.this);
try
{
mediaPlayer.prepareAsync();
}
catch (IllegalStateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
progressBar.setVisibility(ProgressBar.VISIBLE);
progressBar.setProgress(0);
progressBar.setMax(duration);
new Thread(this).start();
}
SETONCOMPLETELISTENER 的规格:
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer mp)
{
i++;
if(i<10)
{
classifica.setText("Canzoni riprodotte: "+String.valueOf(i+1)+"/10 \nPunteggio: "+punteggio);
mp.stop();
Log.d("MPLAY", "MP Stopped");
mp.reset();
Log.d("MPLAY", "MP Reset");
PlayStream(dieciCanzoni.get(i).get(0));
tv.setText(dieciCanzoni.get(i-1).get(1) + "\n" + dieciCanzoni.get(i-1).get(2));
new DownloadImageTask((ImageView) findViewById(R.id.albumImage)).execute(dieciCanzoni.get(i-1).get(4));
iv.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(dieciCanzoni.get(i-1).get(3)));
startActivity(intent);
}
});
}
else
{
FineRound();
}
}
});
日志猫:
11-13 19:42:47.835: D/MPLAY(1981): MP Started
11-13 19:43:17.915: D/MPLAY(1981): MP Stopped
11-13 19:43:17.935: D/MPLAY(1981): MP Reset
11-13 19:43:17.940: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:17.990: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:17.990: E/MediaPlayer(1981): stop called in state 4
11-13 19:43:17.995: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:17.995: D/MPLAY(1981): MP Stopped
11-13 19:43:18.235: D/MPLAY(1981): MP Reset
11-13 19:43:18.235: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:18.270: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:18.285: E/MediaPlayer(1981): stop called in state 4
11-13 19:43:18.285: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:18.295: D/MPLAY(1981): MP Stopped
11-13 19:43:18.450: D/MPLAY(1981): MP Reset
11-13 19:43:18.450: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:18.470: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:18.475: E/MediaPlayer(1981): stop called in state 4
11-13 19:43:18.475: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:18.475: D/MPLAY(1981): MP Stopped
11-13 19:43:18.690: D/MPLAY(1981): MP Reset
11-13 19:43:18.690: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:18.735: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:18.735: E/MediaPlayer(1981): stop called in state 4
11-13 19:43:18.740: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:18.740: D/MPLAY(1981): MP Stopped
11-13 19:43:19.105: D/MPLAY(1981): MP Reset
11-13 19:43:19.105: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:19.185: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:19.185: E/MediaPlayer(1981): stop called in state 4
11-13 19:43:19.190: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:19.190: D/MPLAY(1981): MP Stopped
11-13 19:43:19.680: D/MPLAY(1981): MP Reset
11-13 19:43:19.680: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:19.780: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:19.800: E/MediaPlayer(1981): stop called in state 4
11-13 19:43:19.800: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:19.800: D/MPLAY(1981): MP Stopped
11-13 19:43:20.010: D/MPLAY(1981): MP Reset
11-13 19:43:20.015: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:20.130: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:20.130: E/MediaPlayer(1981): stop called in state 4
11-13 19:43:20.135: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:20.135: D/MPLAY(1981): MP Stopped
11-13 19:43:20.330: D/MPLAY(1981): MP Reset
11-13 19:43:20.330: E/MediaPlayer(1981): error (-38, 0)
11-13 19:43:20.365: E/MediaPlayer(1981): Error (-38,0)
11-13 19:43:22.105: D/MPLAY(1981): MP Started
11-13 19:43:25.590: W/IInputConnectionWrapper(1981): showStatusIcon on inactive InputConnection
11-13 19:43:25.615: D/OpenGLRenderer(1981): Flushing caches (mode 0)
11-13 19:43:26.140: D/OpenGLRenderer(1981): Flushing caches (mode 1)