• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: get iTunes songs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get iTunes songs


  • Subject: Re: get iTunes songs
  • From: John Stiles <email@hidden>
  • Date: Mon, 16 Oct 2006 12:00:23 -0700

Are you certain that the XML is always up to date?
For example, if the user opens up iTunes and adds a song, the XML might not reflect that song immediately.
I believe AppleScript is still the way to go; you just need to minimize the number of transactions. There's no need to do a separate transaction for each property of each song; that's going to produce bad results.



On Oct 16, 2006, at 11:46 AM, Niels Meersschaert wrote:

There is no need to fall back to using AppleScript to retrieve that data if you are writing a Cocoa app. The fastest way is to simply read the iTunes xml file (which is a plist) loaded into an NSDictionary. Connect that dictionary with some minimal glue code as the datasource to your tableview & you're done.

If you want to map the dictionary values to your own object/s, you can quickly iterate thru the dictionary, though there is potential for some performance bottlenecks there due to key-value overhead, but nowhere near the level of using AppleScript. I've found that populating core data objects from iTunes can be as much as 20 seconds for loading 10,000 tracks on an 876mhz G4 PowerBook & populating the tableview. Same code on intel iMac (1.83) takes less than 3 seconds. That's without even bothering with any performance tuning.

Niels

On Oct 16, 2006, at 12:39 PM, John Stiles wrote:

Ah, I see. You're doing thousands of tiny transactions instead of one big transaction.
There is a way to do what you want but probably not via EyeTunes directly. You may have to look into how to send AppleEvents, and how to ask iTunes for "all tracks" instead of just one. Honestly this is outside the scope of what I have personally done, but it seems doable to me.



Olariu Adrian Mihai wrote:
The performance is affected only by the code in which I get information about a track like : [track name], [track time] and so one. Is there a way to get all the tracks instantly like an "automator" does? I rely need a fast solution to get all the tracks and all information for each of them from itunes.

John Stiles wrote:
Does it affect the performance if you comment out this bit?
            if (![artist isEqualToString:@""])
           if (![artistArray containsObject:artist])
               [artistArray addObject:artist];
This seems very slow as you are walking your entire artist array for every song you load.
This could be a lot faster if you used a dictionary, but as a first test, just comment it out and see if it affects things.



Olariu Adrian Mihai wrote:
If I have about 5000 tracks in the library mand it takes about 20 seconds to load all the track in my table view. Below is the code that I use to load tracks.

   while (track = [trackEnum nextObject])
   {

id obj=[trackArray objectAtIndex:count];
count++;
if ([track databaseId] == [currentTrack databaseId])
{
currentTrackObject = obj;
[obj setValue:[playIcon image] forKey:@"Status"];
}
NSString *artist = [track artist];
[obj setValue:track forKey:@"Track"];
[obj setValue:[track name] forKey:@"Name"];
[obj setValue:[track time] forKey:@"Time"];
[obj setValue:artist forKey:@"Artist"];
[obj setValue:[track album] forKey:@"Album"];
[obj setValue:[[NSNumber alloc] initWithInt:[track rating]/20 ] forKey:@"MyRating"];
if (![artist isEqualToString:@""])
if (![artistArray containsObject:artist])
[artistArray addObject:artist];
}



John Stiles wrote:
I think Automator will be doing the same basic thing as EyeTunes—using AppleEvents to get a list of all available songs.
Could you post the EyeTunes code that was too slow for you?
How slow was too slow?


Olariu Adrian Mihai wrote:
I want to create an application that get all the songs from itunes library and display them in a tableview.
I have tried EyeTunes framework but is to slow for what I am trying to do. I see that from an "Automator" application it is possible to get all the tracks from itunes library but how can I include this functionality in my application?


Thanks.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com


This email sent to email@hidden




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com


This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: get iTunes songs
      • From: "John C. Daub" <email@hidden>
References: 
 >get iTunes songs (From: Olariu Adrian Mihai <email@hidden>)
 >Re: get iTunes songs (From: John Stiles <email@hidden>)
 >Re: get iTunes songs (From: Olariu Adrian Mihai <email@hidden>)
 >Re: get iTunes songs (From: John Stiles <email@hidden>)
 >Re: get iTunes songs (From: Olariu Adrian Mihai <email@hidden>)
 >Re: get iTunes songs (From: John Stiles <email@hidden>)
 >Re: get iTunes songs (From: Niels Meersschaert <email@hidden>)

  • Prev by Date: Re: get iTunes songs
  • Next by Date: Re: NSUserDefaults and binding to an NSDictionary
  • Previous by thread: Re: get iTunes songs
  • Next by thread: Re: get iTunes songs
  • Index(es):
    • Date
    • Thread