如何发挥在Android的在线广播 [英] How to play online radio in android

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

问题描述

我工作的Andr​​oid应用程序中,我有玩网络电台串流。    我已经通过媒体播放器类走了,但我不认为有任何方法对无线电的在线流媒体。如果有任何知道这个,请帮助我。

I am working on android application in which i have play online radio streaming. i have gone through the media player classes but i don't think is there any method to online streaming of radio. If any know about this please help me.

感谢你。   维克拉姆

Thank You. Vikram

推荐答案

维克拉姆,

您应该能够使用的MediaPlayer来实现这一点;但是,根据您的格式可能很难。例如,如果你想播放使用.PLS,或m3u格式的在线广播流,你就必须分析该文件,并拉出真正的网址使用。

You should be able to achieve this using the MediaPlayer; however, depending on your format it may be difficult. For example, if you're trying to play an online radio stream that uses .pls, or .m3u, you would have to parse that file, and pull out the true URLs to use.

除此之外,你应该能够使用MediaPlayer的方法,创建一个URL开始流播放。请记住,如果流URL重定向(它很可能如此),你可能需要解析URL。一个简单的方法做,这是使用的HttpURLConnection打开一个连接,然后连接(),然后的getURL()。你可能会需要一个字符串的URL,因此从的getURL()的结果调用toExternalForm()。

Beyond that, you should be able to use MediaPlayer's create method with a URL to start streaming playback. Keep in mind that if the streams URL redirects (which it likely does) you may have to resolve the URL. A simple way to do this is use HttpURLConnection to open a connection, then connect(), then getURL(). You'll likely need a string url, so call toExternalForm() on the result from getURL().

此外,如果事情不通过网址为你工作用的MediaPlayer,你可能要拿出自己的缓冲机制,以从服务器获取数据。既然如此,你可以试试这个教程:<一href="http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/">http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/

Additionally, If things aren't working for you with MediaPlayer via URL, you might have to come up with your own buffering mechanism to get the data from the server. That being the case, you can try this tutorial: http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/

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

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