Streaming internet radio error android

2019-08-12 02:31发布

I am trying out to play internet radio with an example downloaded from
http://www.4shared.com/zip/OTcJZZft/StreamingRadio.html
which works kinda like given in this example Online radio streaming app for Android, but the problem is my logcat keeps throwing this error:

11-07 17:20:39.207: E/MediaPlayer(335): error (1, -1002)
11-07 17:20:39.237: E/MediaPlayer(335): Error (1,-1002)
11-07 17:20:48.882: W/KeyCharacterMap(335): No keyboard for id 0
11-07 17:20:48.886: W/KeyCharacterMap(335): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

I am unable to understand what this means. Can someone please explain what it means and also if someone can guide me to a fresh tutorial for internet radio streaming it would be great help.

Thanks.

1条回答
霸刀☆藐视天下
2楼-- · 2019-08-12 03:10

MediaPlayer is throwing that error (1, -1002) in response to the URL you passed it in the setDataSource(String) method. Set up an onErrorListener() for your MediaPlayer object and catch the error thrown by the player. (Quick look at the documentation - http://developer.android.com/reference/android/media/MediaPlayer.OnErrorListener.html) You can evaluate the error by checking the code thrown via the logcat or a Toast object and take appropriate action based on that.
In my experience with playing internet radio I've found that most often, that or similiar errors thrown by the MediaPlayer are caused by the stream being invalid from the server or the station is no longer viable through that URL. Try to gather several other links and try them to see which ones work and which do not.

查看更多
登录 后发表回答