如何在从shoutcast流中检索元数据时了解新歌曲信息
背景: 我正在使用双缓冲方法来播放 html 的广播电台。我使用 http://www.smackfu.com/stuff/programming/ 从流中获取元数据信息shoutcast.html
问题 我有三个问题。
1-我已经使用 urlconnection 和 inputstream 来收听广播。我不想打开新连接来检索元数据。但是当我尝试从同一输入流获取两者时,我无法再听广播了。我想这是不可能的,我必须使用两个单独的连接?这对性能不是很不利吗?
2-当应用程序启动时,我检索当前歌曲的信息。没问题。然而,当歌曲发生变化时我如何得知。据说当歌曲发生变化时,服务器会发送信息。但我正在启动 URLconnection,获取输入流,检索元数据并关闭连接。我不明白服务器应该如何通知我?我应该保持连接打开吗?
3-最后一个问题。 AFAIK 渐进式流媒体在 android 2.2 之前是不可能的。这仅适用于 http 吗?如果协议是rtsp,我可以在android 2.2之前进行渐进式流传输吗?有人请说清楚吗?
多谢,
Background:
I'm streaming radio using double buffering approach for html shoutcast. I get metadata information from stream using http://www.smackfu.com/stuff/programming/shoutcast.html
Problem
I have three problems.
1- I already use a urlconnection and inputstream for listening radio. I don't want to open a new connection to retrieve metadata. But when I tried to get both from same inputstream, I couldn't listen radio anymore. I guess this is not possible and I have to use two seperate connection? Isn't it bad for performance?
2- When the application started, I retrieve the info of the current song. No problem. However how do I get informed when the song changes. It is said that server will send information when the song changes. But I'm starting the URLconnection, get the input stream, retrieve the metadata and close the connection. I couldn't understand how should I informed by the server? Should I keep the connection open?
3- And last question. AFAIK progressive streaming isn't possible before android 2.2. Is this true just for http? If the protocol was rtsp, could I make progressive streaming before android 2.2? Anyone please make it certain and clear?
Thanks a lot,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须记住 icy-metaint 标头字段中的数字。
从流中接收到那么多字节(发送到音频解码器)后,您必须期待元数据部分,并读取它(也不将这些数据发送到音频解码器)。
然后,您再次从流中接收编码音频,并继续在 icy-metaint 字节之后定期读取元数据的过程。
这意味着服务器定期发送元数据(有关艺术家/歌曲标题的信息),并且您的代码必须将输入流拆分为音频和元数据。
You must remember number from icy-metaint header field.
After receiving that many bytes from stream (which you send to audio decoder), you must expect metadata part, and read this (also not sending these data to audio decoder).
Then you again receive encoded audio from stream, and continue the process of periodically reading metadata after icy-metaint bytes.
This means that server sends metadata (info about artist / song title) periodically, and your code must split the input stream to audio and metadata.