【问题标题】:Getting mp3's from documents folder从文档文件夹中获取 mp3
【发布时间】:2014-08-05 12:00:31
【问题描述】:

这个问题是关于 Objective-C、Xcode 和 iOS 的。我想访问应用程序文档文件夹中的 mp3 或 m4a 文件并获取这些文件 MPMediaItemPropertyTitleMPMediaItemPropertyAlbumTitleMPMediaItemPropertyArtist 信息。之后我想播放这些文件。实际上我想做一个音乐播放器应用程序,我需要帮助。提前谢谢...

【问题讨论】:

  • 应用程序文档文件夹是什么?有一个应用程序文件夹,一个应用程序包,以及每个用户的文档文件夹。你需要澄清..
  • 我的意思是文档文件夹@cacau

标签: ios objective-c xcode ios7


【解决方案1】:

您可以使用以下代码获取 mp3file 数组并使用 AVAudio 播放器播放它

-(void)getallMp3Files
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSArray *filePathsArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory  error:nil];
    NSMutableArray *arrMp3Files=[[NSMutableArray alloc]init];
    for (NSString *str in filePathsArray) {
        NSString *strFileName=[str.lastPathComponent lowercaseString];
        if([strFileName.pathExtension isEqualToString:@"mp3"])
        {
        NSLog(@"%@",str);
            [arrMp3Files addObject:str];
        }

    }
}

【讨论】:

    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 2013-05-17
      • 1970-01-01
      • 2012-12-01
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      • 2013-10-14
      • 1970-01-01
      相关资源
      最近更新 更多