在iPhone App中播放M4A文件的最佳方法

时间:2010-09-06 00:08:37

标签: iphone

问候,

我有一个tableview,我已经解析了播客列表(m4a格式)。我想现在播放播客。我见过Matt Gallaghers的方法,但对于我需要的东西似乎有些过分。我记得看到一个教程,你可以在UIWebview中播放这样的文件,但它似乎不起作用。任何建议将不胜感激。提前谢谢。

1 个答案:

答案 0 :(得分:1)

NSString * basePath = [NSHomeDirectory() 
           stringByAppendingPathComponent:@"Documents"];

basePath=[basePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
basePath=[basePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];    

NSURL * baseURL = [NSURL URLWithString: [NSString      
                             stringWithFormat:@"file:/%@//",basePath]]; 

NSString *html = @"<html><body><audio src=\"test.mp3\" 
                                      controls></audio></body></html>";
[self.view loadHTMLString:html baseURL:baseURL];

我重写了代码并使其工作,catch是处理文档基本路径中的空白,这对我来说是个问题。