Palsofiphone Palsofiphone - 3 months ago 14
iOS Question

Is it possible to get data or songs of music player in iPhone app?

Hello first of all I am new in iPhone,

I want access all songs in my application. Is this posible to get all songs ?

Thank you very much. May be it's easy for you but for me it's hard.

Answer

You need the Media Player framework:

  • MPMediaLibrary, MPMediaQuery, etc.
  • iPod Library Access Programming Guide

Actual example taken from the docs:

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

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