Android mediaplayer MediaPlayer(658): error (1, -2147483648)

为君一笑 提交于 2019-12-18 05:00:14

问题


I get this error when playing a streaming audio in Android:

MediaPlayer(658): error (1, -2147483648)

mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepareAsync();

回答1:


I don't know about playing streams but I was getting the same error from trying to play a file residing on the device. The solution was that the MediaPlayer didn't have the right permissions to read the video file. This article helped me out tremendously. http://www.weston-fl.com/blog/?p=2988




回答2:


I was also getting the same error on Froyo & Gingerbread. In higher Androids the same video played well. Finally after a lot of research, tried changing the Https Url to Http Url & Bingo. It resolved my issue. I was using amazon S3 server so that simply replacing the "https" in url with "http" was sufficient.

  videoUrl= videoUrl.replaceFirst("https", "http"); 

PS: For supporting older versions if you are using H.264 make sure videos are Baseline encoded.




回答3:


From the information you provided it is not possible to tell what is wrong exactly. You use prepareAsync() method, have you registered onPreparedListener? The prepareAsync method returns immediately, without onPreparedListener you do not have information when it is ready to start playing.

The other possibility is an error in your URL, or unsupported streaming protocol...




回答4:


After many try/error tests, for me has worked using full path on "new Media(...)", like this:

var mySound = new Media('file:///android_asset/www/sound/mysound.mp3');

S.



来源:https://stackoverflow.com/questions/8236095/android-mediaplayer-mediaplayer658-error-1-2147483648

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!