MediaPlayer的错误,当试图从流播放 [英] MediaPlayer error when attempt to play from a stream
问题描述
有谁知道是什么,第二个参数从这一错误中的的意思是(1,-2147483648)在MediaPlayer的?我不断地试图从URL流播放音频时收到它。我试图把它从一个扩展BaseExpandableListAdapter如果此事一类游戏。我已经审阅这篇文章<一个href="http://stackoverflow.com/questions/10795388/android-mediaplayer-error-mediaplayer-error1-2147483648-on-stream-from-inte">Android MediaPlayer的错误:MediaPlayer的错误(1,-2147483648)的流从互联网上但所有的答案是指流支持问题。这不是我的情况下,流支持的问题,因为我能够从同一个流播放音频,但只使用一个不同的类。这是我使用的演奏方法:
私人无效startPlaying(字符串文件名){
媒体播放器=新的MediaPlayer();
尝试 {
如果(的FileInputStream!= NULL){//从文件系统读取从一个FileInputStream文件(内部或外部存储)
mediaPlayer.setDataSource(fileInputStream.getFD());
Log.d(从设备,MediaPlayer正在玩);
} 其他 {
//媒体播放器=新的MediaPlayer();
mediaPlayer.setDataSource(getFilePath()); //从URL中读取一个文件
Log.d(从流的MediaPlayer播放);
}
媒体播放器prepare()。
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(新CompletionListener());
}赶上(IOException异常E){
Log.e(LOG_TAG,prepare()失败);
}
}
该错误通常是这些在这种情况一:
- 在文件路径是错误的。不正确的目录或URL或URI中。
- 在媒体文件是错误的,不兼容的格式。
- 缺少权限
下面是一个很好的博客,概述了这些情况,如何解决这些问题:
http://www.weston-fl.com/blog/?p= 2988
另请参阅该主题:
<一个href="http://stackoverflow.com/questions/8236095/android-mediaplayer-mediaplayer658-error-1-2147483648?rq=1">android媒体播放器MediaPlayer的(658):错误(1,-2147483648)
Does anybody know what does the second argument mean from this error (1, -2147483648) in MediaPlayer? I constantly receive it when attempting to play an audio from a url stream. I try to play it from a class that extends BaseExpandableListAdapter if that matter. I have already reviewed this post Android MediaPlayer error: MediaPlayer error(1, -2147483648) on Stream from internet however all the answers refers to the stream support issues. It's not a stream support issue in my case since I am able to play an audio from the same stream but just using a different class. This is a method that I'm using for playing:
private void startPlaying(String fileName) {
mediaPlayer = new MediaPlayer();
try {
if (fileInputStream != null) { // Read a file from a fileInputStream from a filesystem (EXTERNAL OR INTERNAL storage)
mediaPlayer.setDataSource(fileInputStream.getFD());
Log.d("MediaPlayer is playing", "from device");
} else {
// mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(getFilePath()); // Read a file from a url
Log.d("MediaPlayer is playing", "from stream");
}
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(new CompletionListener());
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
The error is usually one of these in this case:
- File path is in error. Incorrect directory or Url or Uri found.
- Media file is in error, incompatible format.
- Missing permissions
Here's a good blog that outlines these situations and how to fix them:
http://www.weston-fl.com/blog/?p=2988
Also see this thread:
android mediaplayer MediaPlayer(658): error (1, -2147483648)
这篇关于MediaPlayer的错误,当试图从流播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!