开发者

android playing streaming pls files

I'm currently building an application and I need your help.

This application can play streaming .pls files from the internet. The problem is I can't figured out what cla开发者_Python百科ss to play streaming pls file.

I had used the MediaPlayer class, but it got error and stopped working.

This is my piece of code in executing the mediaplayer :

try {
                mediaPlayer.setDataSource(site);
            } catch (IllegalArgumentException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (IllegalStateException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
try {
                    mediaPlayer.prepare();
                } catch (IllegalStateException e) {
                    // TODO Auto-generated catch block
                    Log.e (getClass().getName(), "Cannot Play Stream..");
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    Log.e (getClass().getName(), "Cannot Play Stream..");
                    e.printStackTrace();
                }
                    mediaPlayer.start();
                    break;

What should I do ?? need help, THX (the try-catch statement is automatic in eclipse. I can't compile without the try-catch statement)


As far as I know you can't play PLS files directly with any of the Android music/sound player classes.

I would use HttpGet to download the PLS file and then process it to extract the URL it contains. Once you have the URL of the stream, you can pass that to MediaPlayer and it should play it OK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜