Open bettocr opened 11 years ago
Look at the structure of the files, they should contain the URL for the actual stream.
Try curl http://www.supremeradio.it/supreme.pls in Terminal
I have a simple function which get the first adress in the pls and return it. I have one for m3u too but this maybe makes more clear when you can see a okay example.
- (NSString*)getAddressFromPLS:(NSURL *)url
{
NSString *plsurl = @"";
NSError* error = nil;
NSString *fileContents = [NSString stringWithContentsOfURL: url
encoding: NSUTF8StringEncoding
error: &error];
if(![fileContents hasPrefix:@"ICY 404"]) {
if(fileContents && !error) {
NSMutableArray *lines = [fileContents componentsSeparatedByString:@"\n"];
for(int i = 0;i<[lines count];i++)
{
if([[lines objectAtIndex:i] hasPrefix:@"File1="])
{
plsurl = [[lines objectAtIndex:i] stringByReplacingOccurrencesOfString:@"File1=" withString:@""];
}
}
}
}
else
{
plsurl = @"";
}
NSLog(@"Address: %@", plsurl);
return plsurl;
}
在 2013年6月12日星期三,Håkan Nylén 写道:
I have a simple function which get the first adress in the pls and return it. I have one for m3u too but this maybe makes more clear when you can see a okay example.
- (NSString)getAddressFromPLS:(NSURL )url{ NSString plsurl = @""; NSError error = nil; NSString fileContents = [NSString stringWithContentsOfURL: url encoding: NSUTF8StringEncoding error: &error]; if(![fileContents hasPrefix:@"ICY 404"]) { if(fileContents && !error) { NSMutableArray lines = [fileContents componentsSeparatedByString:@"\n"]; for(int i = 0;i<[lines count];i++) { if([[lines objectAtIndex:i] hasPrefix:@"File1="]) { plsurl = [[lines objectAtIndex:i] stringByReplacingOccurrencesOfString:@"File1=" withString:@""]; } } } } else { plsurl = @""; } NSLog(@"Address: %@", plsurl); return plsurl;}
— Reply to this email directly or view it on GitHubhttps://github.com/mattgallagher/AudioStreamer/issues/61#issuecomment-19313298 .
Greetings!
I wonder if you can use an m3u or pls file, I've tried everything and I've failed.
thanks