简体   繁体   English

从shoutcast iOS 编程中获取元数据

[英]Getting Metadata from shoutcast iOS programming

Hello I am trying to parse Shoutcast radio's metadata in iOS.您好,我正在尝试在 iOS 中解析 Shoutcast 广播的元数据。

After trying many submitted solutions, I end up with a piece of code that is still giving me error在尝试了许多提交的解决方案后,我最终得到了一段仍然给我错误的代码

Response String: ICY 404 Resource Not Found icy-notice1:响应字符串:ICY 404 资源未找到 icy-notice1:
SHOUTcast Distributed Network Audio Server/Linux v1.9.8 SHOUTcast分布式网络音频服务器/Linux v1.9.8
icy-notice2:The resource requested was not found冰雪通知2:未找到请求的资源

the code im trying to parse metadata我试图解析元数据的代码

NSURL *url = [NSURL URLWithString:@"http://relay.181.fm:8052/7.html"];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0];

   [request addValue:@"1" forHTTPHeaderField:@"icy-metadata"];
   [request addValue:@"Winamp 5/3" forHTTPHeaderField:@"User-Agent"];
   [request addValue:@"audio/mpeg" forHTTPHeaderField:@"Content-Type"];

[request setHTTPMethod:@"GET"];

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSString* responseString = [[NSString alloc] initWithData:data encoding: NSUTF8StringEncoding];

NSLog(@"Response String: %@", responseString);

any ideas about problem, thanks for helping关于问题的任何想法,感谢您的帮助

Not all SHOUTcast servers allow access to 7.html .并非所有 SHOUTcast 服务器都允许访问7.html There are two other ways to get that data.还有另外两种方法可以获取这些数据。

The XML data for SHOUTcast is generally available, but requires the server's password. SHOUTcast 的 XML 数据通常是可用的,但需要服务器的密码。 You can request it using /admin.cgi?mode=viewxml&page=4 .您可以使用/admin.cgi?mode=viewxml&page=4请求它。

You can also read the metadata right out of the stream.您还可以直接从流中读取元数据。 This is more cumbersome, but entirely possible, and not too difficult.这比较麻烦,但完全可以,而且也不太难。 See this answer for details: https://stackoverflow.com/a/4914538/362536有关详细信息,请参阅此答案: https : //stackoverflow.com/a/4914538/362536

I found a solution for those who can't/doesn't want to read metadata from stream.我为那些不能/不想从流中读取元数据的人找到了解决方案。 Its the easiest solution I have seen.这是我见过的最简单的解决方案。

http://www.fvalente.org/blog/2012/03/15/shoutcast-metadata-the-easy-way/ http://www.fvalente.org/blog/2012/03/15/shoutcast-metadata-the-easy-way/

Brad says in the post above布拉德在上面的帖子中说

Not all SHOUTcast servers allow access to 7.html.并非所有 SHOUTcast 服务器都允许访问 7.html。

so it is better to check if the server you want to get metadata has /7.html page所以最好检查一下你要获取元数据的服务器是否有/7.html页面

the current song is also displayed on the page /played.html but it works in a web browser along with /7.html.当前歌曲也显示在页面 /played.html 上,但它与 /7.html 一起在网络浏览器中工作。 But when i tried in fiddler2 on a windows machine i got the ICY 404 resource not found error但是当我在 Windows 机器上的 fiddler2 中尝试时,我得到了 ICY 404 资源未找到错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM