开发者

How to play online stream in Android

开发者 https://www.devze.com 2023-04-01 09:39 出处:网络
Ihave online radio (shout cast ) in开发者_JAVA技巧 web. I want to develop android app for listen this stream. so I want to know how to play online stream in android. using URL. In Android Im not going

I have online radio (shout cast ) in开发者_JAVA技巧 web. I want to develop android app for listen this stream. so I want to know how to play online stream in android. using URL. In Android Im not going to Stream the audio. I want listen the web stream from android app. How to do that..? thanks


Something like

private void init() throws IOException {
    try {
        mediaPlayer = new MediaPlayer();
        String streamPath = "";//enter path
        mediaPlayer.setDataSource(streamPath);
        mediaPlayer.prepare();
    } catch (MalformedURLException ex) {
        throw new RuntimeException("Wrong url for mediaplayer! " + ex);
    } catch (IllegalStateException ex) {
    } catch (IllegalArgumentException ex) {
        throw new RuntimeException("Wrong url for mediaplayer! " + ex);
    }
}

private void play() {
    mediaPlayer.start();
}


Please refer the link it may help you a while, http://developer.android.com/guide/topics/media/index.html

0

精彩评论

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