I have several questions regarding filenames and the "iPod Library".
- I understand I can retrieve MPM开发者_JS百科ediaItems from the "iPod Library". How may I get the filename of a MPMediaItem? (I only need to read the filenames, not save to or otherwise modify the library.)
- When an mp3 is added to the iPod library (via iTunes), does it keep its filename?
- May I obtain a list of all filenames within the iPod library? i.e. can contentsOfDirectoryAtPath be used to list filenames from the library?
I don't think this is possible. Not just that, you should also note that even on a jailbroken iphone, the media file names are changed to some random 4-5 char strings.
Even if you get the real file name, you can't do anything much with that.
You can get the URL of the item via the MPMediaItemPropertyAssetURL property.
-(void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection
{
NSArray* items = [ mediaItemCollection items ];
if ( [ items count ] )
{
MPMediaItem* mediaItem = [ items objectAtIndex:0 ];
NSURL* url = [ mediaItem valueForProperty:MPMediaItemPropertyAssetURL ];
NSLog( @"%@", url );
}
[ self dismissModalViewControllerAnimated:YES ];
}
It will typically yield urls in the form of: ipod-library://item/item.mp3?id=-5938525213358316745
精彩评论