【问题标题】:delete/hide file from itunes library used in my iphone application从我的 iphone 应用程序中使用的 iTunes 库中删除/隐藏文件
【发布时间】:2012-09-08 05:31:25
【问题描述】:

我制作了一个 iphone 应用程序,在其中我从 iTunes 库中获取歌曲并显示在表格中,并将它们存储在我的文档目录中。现在我想保密..所以我想从 iTunes 库中删除选定的文件,这样它就不会显示在列表中。谁能帮我做到这一点? 代码:

importableDoc = [NSMutableArray array];
// Get public docs dir
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *publicDocumentsDir = [paths objectAtIndex:0];   

// Get contents of documents directory
NSError *error;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:publicDocumentsDir error:&error];
if (files == nil) {
    NSLog(@"Error reading contents of documents directory: %@", [error localizedDescription]);
}

// Add all mp3 files to a list    

for (NSString *file in files) {
    if ([file.pathExtension compare:@"mp3" options:NSCaseInsensitiveSearch] == NSOrderedSame) 
    {        

        NSString *fullPath = [publicDocumentsDir stringByAppendingPathComponent:file];
                //NSLog(@"fullPath : %@",fullPath);

        [importableDoc addObject:fullPath];
    }
  }
}

【问题讨论】:

    标签: iphone objective-c ios itunes


    【解决方案1】:

    抱歉,看来你运气不好。来自Media Player Framework Reference

    媒体播放器框架提供了播放电影的设施, 音乐、音频播客和有声读物文件。该框架还提供 您的应用程序访问 iPod 库,让您查找和播放 从桌面上的 iTunes 同步的基于音频的媒体项目。 iPod 库访问是只读的

    作为替代方案,您可以使用MPMediaQueries 来显示您自己的可用歌曲自定义列表,而不是使用MPMediaPickerController,但这仍然没有让您有机会从用户iPod 库中实际删除曲目。

    【讨论】:

    • 谢谢。但我已经通过另一种方式解决了这个问题。我将歌曲保存到 DocumentLibrary 并从文档目录中删除。意味着我将歌曲保存在文档目录中,并且选定的歌曲将存储在库中并将从文档目录中删除。再次感谢您的回答。 :)
    猜你喜欢
    • 2018-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-31
    • 2013-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多