-1

I'm doing some work with MPMediaItems, and specifically I'm trying to get a list of the videos on a user's device. Now, videos from iTunes will be locked so they can't be played from a third-party app, but user-added videos like home movies are playable, and even those from iTunes can have their meta information queried and displayed.

But here's where I'm getting tripped up: I can't seem to find any video-specific meta info for these files?

The MPMediaItem class reference has a long list of properties that you can access, but they're mostly audio-specific. Things like MPMediaItemPropertyAlbumTitle or MPMediaItemPropertyComposer. There's even a section for Podcast-specific properties, but I can't seem to find anything like "Season Number" or "Episode Number" or "Show Title". This information is obviously stored by iTunes, and it's displayed by the in-house Videos app, but I can't find any way to get it myself.

These are the only fields I can find in the class reference: NSString *const MPMediaItemPropertyPersistentID ; // filterable NSString *const MPMediaItemPropertyAlbumPersistentID ; // filterable NSString *const MPMediaItemPropertyArtistPersistentID ; // filterable NSString *const MPMediaItemPropertyAlbumArtistPersistentID ; // filterable NSString *const MPMediaItemPropertyGenrePersistentID ; // filterable NSString *const MPMediaItemPropertyComposerPersistentID ; // filterable NSString *const MPMediaItemPropertyPodcastPersistentID ; // filterable NSString *const MPMediaItemPropertyMediaType ; // filterable NSString *const MPMediaItemPropertyTitle ; // filterable NSString *const MPMediaItemPropertyAlbumTitle ; // filterable NSString *const MPMediaItemPropertyArtist ; // filterable NSString *const MPMediaItemPropertyAlbumArtist ; // filterable NSString *const MPMediaItemPropertyGenre ; // filterable NSString *const MPMediaItemPropertyComposer ; // filterable NSString *const MPMediaItemPropertyPlaybackDuration; NSString *const MPMediaItemPropertyAlbumTrackNumber; NSString *const MPMediaItemPropertyAlbumTrackCount; NSString *const MPMediaItemPropertyDiscNumber; NSString *const MPMediaItemPropertyDiscCount; NSString *const MPMediaItemPropertyArtwork; NSString *const MPMediaItemPropertyLyrics; NSString *const MPMediaItemPropertyIsCompilation ; // filterable NSString *const MPMediaItemPropertyReleaseDate; NSString *const MPMediaItemPropertyBeatsPerMinute; NSString *const MPMediaItemPropertyComments; NSString *const MPMediaItemPropertyAssetURL; NSString *const MPMediaItemPropertyIsCloudItem ; // filterable

I'm fairly confident that this information isn't available through the MPMediaItemProperties values, but can it be accessed in any other way? Is there even a round-about method for accessing this information, something like this answer which I don't completely understand but which seems promising, or is it completely impossible for a developer to see what show/season a video is from?

EDIT: This became especially important recently, because the most recent version of iTunes now no longer even presents those audio-specific fields (like "Album" or "Artist") when editing video files. Going to "Get Info" on a video file in iTunes now only shows the video-specific fields, meaning that videos input after this update now seem to be completely un-sortable in a third-party app.

...unless someone has an idea?

EDIT 2: In my research I've come across the AVMetadataItem class, which I'd never heard of before, and specifically the AVMetadataiTunesMetadataKey options (class reference). They don't seem to include Show, Season, or Episode info, but they do have some video-specific fields like AVMetadataiTunesMetadataKeyDirector. Is there some other use of this class, or some other video-related class like AVAsset, that might have a roundabout access to the info I'm looking for?

EDIT 3: Got my hopes up when I found the iTunes Library Framework, which includes a ITLibMediaItemVideoInfo class that is EXACTLY what I'm looking for. However, it seems to be Mac-only, and I need it on iOS... Any chance someone has a work-around to access this info on iOS?

Community
  • 1
  • 1
Nerrolken
  • 1,975
  • 3
  • 24
  • 53
  • Did you check to see if iTunes doesn't already store the Episode or Season number in one of those existing fields already? (i.e. MPMediaItemPropertyAlbumTrackNumber) – Oren Mar 31 '15 at 21:17
  • @Oren Yeah, they're all blank for a video file. – Nerrolken Mar 31 '15 at 21:25
  • At least AlbumTitle, Artist, AlbumArtist, AlbumTrackNumber, and Composer are blank. I didn't check every single one, but I don't see them storing Show Name in the Lyrics field, you know? – Nerrolken Mar 31 '15 at 21:34
  • Why would that be in Lyrics? If there's any info on the id3 tags I would expect MPMediaItemPropertyTitle would be populated. Nothing there for you either? – Oren Mar 31 '15 at 22:16
  • @Oren It wouldn't be in Lyrics, my point was that I've checked all the fields where it was likely to be, and I ignored the fields (like Lyrics) where they obviously wouldn't be putting it. MPMediaItemPropertyTitle has data, but that's one of the audio-and-video fields. I'm looking for the fields that pertain only to video files, like Show Name, Season Number, etc. – Nerrolken Mar 31 '15 at 23:01
  • Why the downvote? It's a specific question, clearly stated, with my research detailed and updated as I've continued working on it. – Nerrolken Apr 06 '15 at 19:09
  • You're not really responding to comments anymore, so I'll leave you with this link. Best of luck: https://code.google.com/p/subler/source/browse/trunk/mp4v2+wrapper/MP42AVFImporter.m?r=972 – Drakes Apr 23 '15 at 10:54
  • @Drakes What do you mean? I'm still responding to comments, this is the first one you've left... – Nerrolken Apr 23 '15 at 20:37
  • @Nerrolken Hello, oh, I was wondering if you had any luck with source I provided in my answer, or the media keys, or should I keep digging? :) – Drakes Apr 25 '15 at 05:54
  • @Drakes Awesome, thanks! I didn't see that you'd answered. I'll check out this option ASAP! – Nerrolken Apr 26 '15 at 06:04

1 Answers1

0

This may help you with exactly what are you looking for: https://code.google.com/p/subler/source/browse/trunk/mp4v2+wrapper/MP42AVFImporter.m

Here is a highlight of the relevant section you may be interested in related to AVMetadataKeySpaceiTunes:

...
@"Description",         @"desc",
@"Long Description",    @"ldes",
@"Media Kind",          @"stik",
@"TV Show",             @"tvsh",
@"TV Episode #",        @"tves",
@"TV Network",          @"tvnn",
@"TV Episode ID",       @"tven",
@"TV Season",           @"tvsn",
@"HD Video",            @"hdvd",
@"Gapless",             @"pgap",
@"Sort Name",           @"sonm",
@"Sort Artist",         @"soar",
@"Sort Album Artist",   @"soaa",
@"Sort Album",          @"soal",
@"Sort Composer",       @"soco",
@"Sort TV Show",        @"sosn",
@"Category",            @"catg",
@"iTunes U",            @"itnu",
@"Purchase Date",       @"purd",
... 
Drakes
  • 23,254
  • 3
  • 51
  • 94
  • I've been wrestling with several personal tragedies, so I apologize for not responding about this sooner. But I'm getting back to this project now, and I appreciate your answer! However, unless I'm reading this wrong, the link you provided doesn't actually get the info requested? The code you quoted simply sets `@"TV Episode #"` to a placeholder string, while other properties like `@"Album"` get set to things like `AVMetadataiTunesMetadataKeyAlbum`. Where does it actually *find* the episode number, etc? – Nerrolken May 31 '15 at 01:40