流式传输 .m3u 音频
我想播放流媒体广播(.m3u 格式),但我不知道该怎么做。
这个例子是我如何尝试玩的:
final MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource("url.m3u");
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mp.prepare();
mp.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
此代码不起作用。 请帮忙。
I want play streaming radio( .m3u format ), but i do not know how do it.
This example how i try playing:
final MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource("url.m3u");
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mp.prepare();
mp.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this code does not work.
help please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须先下载 M3U 文件。这只是一个文本文件,逐行读取。每行都有一个链接,您可以在媒体播放器中阅读该链接。
使用这样的东西,
You have to download the M3U file first. It's just a text file, read it line by line. Each line will have a link which you can read in your media player.
Use something like this,
我对流媒体广播也有同样的问题。但就我而言,我刚刚从网址中删除了 .m3u 并且它起作用了!
尝试这样做:
相反
I had the same issue with streaming radio. But in my case I've just removed .m3u from url and it worked!
Try to do this:
instead