Shah Paneri
Shah Paneri

Reputation: 739

delete/hide file from itunes library used in my iphone application

I have made an iphone application in which i am getting songs from itunes library and display in table as well as store them in my document directory. Now i want to make it secret..So i want to delete the selected file from itunes library so it wont be displayed in list. Can anyone help me to do this?? Code:

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];
    }
  }
}

Upvotes: 0

Views: 894

Answers (1)

Mick MacCallum
Mick MacCallum

Reputation: 130222

Sorry, but it looks like you're out of luck. From Media Player Framework Reference:

The Media Player framework provides facilities for playing movie, music, audio podcast, and audio book files. This framework also gives your application access to the iPod library, letting you find and play audio-based media items synced from iTunes on the desktop. iPod library access is read-only.

As an alternative, instead of using a MPMediaPickerController you could use MPMediaQueries to display your own custom list of songs available, but that still doesn't give you to opportunity to actually remove tracks from the users iPod library.

Upvotes: 3

Related Questions