2009-12-14 100 views
2

Iam创建和无线电应用程序,其中我必须检查身份验证和成功登录后,我得到.pls文件,其中有实际的网址必须播放 任何人都知道如何解析.pls文件并获取.pls文件中的url。.Pls文件解析

回答

0

在我来说,我在主束一WWEMAC.pls文件。其中存在多个url,我只需提取这些URL并以字符串格式将它们添加到数组中。以下代码为我工作。

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"WWEMAC" ofType:@"pls"]; 
NSError *errorReading; 
NSArray *linesOfText = [[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&errorReading] componentsSeparatedByString:@"\n"]; 
NSLog(@"Reading error %@",errorReading); 
NSString *completeDataInStr = [linesOfText componentsJoinedByString:@" "]; 
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil]; 
NSArray *matches = [detector matchesInString:completeDataInStr options:0 range:NSMakeRange(0, [completeDataInStr length])]; 
for (NSTextCheckingResult *match in matches) 
{ 
    NSString *str = [NSString stringWithFormat:@"%@",match.URL]; 
    NSLog(@"URL str = %@",str); 
} 
return matches; 
+0

WWEMAC.pls文件包含有像这样 [流列表] File1中= HTTP://stream.com:80/WWW_PC File1中= HTTP://stream.com:81/WWW_PC 文件2 = HTTP://stream.com:82/WWW_PC 文件3 = HTTP://stream.com:83/WWW_PC FILE4 = HTTP://stream.com:84/WWW_PC File5 = HTTP://stream.com :85/WWW_PC Title1 = WWEMAC_PC 长度1 = -1 NumberOfEntries = 5 版本= 5 并返回数组(命名为matches here)co仅允许来自.pls文件的URL。 – 2015-09-23 13:39:04