Mediaplayer错误(-38,0),停止在状态4调用

结果是,前两首歌曲播放的很好,但是其他歌曲却没有播放,并且没有播放任何东西而到达最后一首歌曲!

播放stream的代码(它的工作原理):

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

SETONCOMPLETELENENER的规格:

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

logcat的:

 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) 

Solutions Collecting From Web of "Mediaplayer错误(-38,0),停止在状态4调用"

是的,我可以随时帮忙。 我也有这个错误我的解决scheme是检查pathAS ANDROID MEDIA PLAYER RECIEVES IT。 所以要做到这一点粘贴此代码:

 Log.d("MediaPlayer Datasource" , "The datasource is: " + url); 

检查url是否正确并包含扩展名。 确保它没有被域保护。

如果一切正常,并且贴上这个代码:

 mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { // TODO Auto-generated method stub mediaPlayer.start(); } }); 

我知道你们都已经准备好了,但也许这不起作用。

使用3GPvideo文件,它将正常工作…