Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3564] iOS: Expose MPMediaQuery

GitHub Issuen/a
TypeNew Feature
Resolution Date2011-07-27T13:32:12.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sSprint 2011-30, Release 1.8.0
ReporterDawson Toth
AssigneeStephen Tramer



Expose MPMediaQuery so that users can query the media library.

Apple Documentation

http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/iPodLibraryAccess_Guide/UsingTheiPodLibrary/UsingTheiPodLibrary.html"> http://developer.apple.com/library/ios/#documentation/Audio/Concept...

Sample ObjC

The following logs all of the artist names on the device.

MPMediaQuery *everything = [[MPMediaQuery alloc] init];

NSLog(@"Logging items from a generic query...");
NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *song in itemsFromGenericQuery) {
    NSString *artistName = [song valueForProperty: MPMediaItemPropertyArtist];
    NSLog (@"%@", artistName);

Associated Helpdesk Ticket



  1. Stephen Tramer 2011-07-25

    There is a new test in KS (and a reorganization of the 'Music' tests) for this feature. - 'Phone -> Music' now points to a selection of multiple music tests - 'Phone -> Music -> Music Picker' is the old 'Phone -> Music' test - The new 'Phone -> Music -> Music Query' test runs as: ---- This test must be run on a device with media installed for the iPod. Clicking the 'Query! [check your log]' button will produce output in the log like the following, consisting of (title, artist, genre) triplets: {quote} [INFO] 0: (Bioshock Main Theme (The Ocean on His Shoulders),Garry Schyman,Game) [INFO] 1: (The Ocean,Led Zeppelin,Rock) [INFO] 2: (The Ocean Is The Ultimate Solution,Frank Zappa,Alternative & Punk) [INFO] 3: (Ocean Man,Ween,Rock) [INFO] 4: (Ocean of Lust,DeVotchKa,Rock) [INFO] 5: (Porcelina Of The Vast Oceans,Smashing Pumpkins,Alternative & Punk) [INFO] 6: (Songs Of The Ocean,Star One,Progressive Metal) [INFO] 7: (Songs Of The Ocean,Star One,Progressive Metal) {quote} Or a 'No results!' result, indicating a nonmatch. 1. Each text field indicates an ID3 tag in the media library to match against as part of the query. 2. The 'exact' toggles turns on/off exact matching. Exact matching INCLUDES case-sensitivity. 3. With all fields empty, regardless of 'exact'ness, the result should be all media installed on the device. 4. Results should be sorted alphabetically by title TESTING ---- Simply make sure that some sensible values are returned for various title/artist/genre configurations. The smaller the amount of media installed on the device, the better (it's actually best to install a small set of songs filtered in itunes by title, because this will also give you some data to validate the full list/title "inexact" search against).
  2. Michael Pettiford 2012-02-10

    Closing issue Tested with Ti Studio build Ti Mob SDK 1.9.0.v20120209183134 OSX Lion 10.7.3 iPhone 4S OS 5.0.1 Verified that the expected behavior is shown from the new KS tests

JSON Source