如何在Android中播放在线流媒体广播 [英] How to Play the online streaming radio in Android

查看:231
本文介绍了如何在Android中播放在线流媒体广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个想要播放直播广播的应用程序.我有一个URL,通过它我可以广播和播放广播.通过单击要播放收音机的按钮,我有一个播放按钮.为此,我写了一些根本不起作用的代码.这是我的代码:

I am developing one application where i want to play live stream radio. I have an url using which i will stream the radio and play. I have a play button by clicking which i want to play the radio. For that, i have written some code which is not at all working. Here is my code:

mp = new MediaPlayer();
try {

    mp.setOnPreparedListener(this);
    Log.d("Testing", "start111");
    mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
    String url="xxxxxx";
    mp.setDataSource(url);
    mp.prepareAsync();
} catch (IllegalArgumentException e) {
    e.printStackTrace();
    Log.d("Testing", "Exception ::: 1111 "+e.getMessage());
} catch (IllegalStateException e) {
    Log.d("Testing", "Exception ::: 2222 "+e.getMessage());
    e.printStackTrace();
} catch (IOException e) {
    Log.d("Testing", "IOException ::: 3333 "+e.getMessage());
    e.printStackTrace();
}

任何人都可以帮助我吗?

Can anyone please help me??

推荐答案

您可以找到有关广播流的良好信息. Github广播流示例

You can find good information regarding radio streaming. Github radio streaming example

还有SOF中的一个问题,可能也有帮助 Stackoverflow广播流示例

and also there is a question in SOF which can also be helpful Stackoverflow radio streaming example

希望它会有所帮助.谢谢

Hope it will help. thanks

这篇关于如何在Android中播放在线流媒体广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆