Hello I am trying to parse Shoutcast radio's metadata in iOS.
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:
SHOUTcast Distributed Network Audio Server/Linux v1.9.8
icy-notice2:The resource requested was not found
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. There are two other ways to get that data.The XML data for SHOUTcast is generally available, but requires the server's password. You can request it using
/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