开发者

iPod library: obtain the filename of a media item

I have several questions regarding filenames and the "iPod Library".

  1. 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.)
  2. When an mp3 is added to the iPod library (via iTunes), does it keep its filename?
  3. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜