• 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: No track index in iTunes SB?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No track index in iTunes SB?


  • Subject: Re: No track index in iTunes SB?
  • From: Adam P Jenkins <email@hidden>
  • Date: Mon, 10 Mar 2008 19:25:39 -0400


On Mar 10, 2008, at 12:14 PM, has wrote:

slasktrattenator wrote:

Anyone know how to get the index of the current iTunes track using
Scripting Bridge? With Applescript, it's as simple as "tell iTunes to
return index of current track", but iTunes SB has no such property
(well, there is one, but it only refers to the index of the current
playlist). It seems the iTunesTrack index property is simply
missing...? Or am I missing something?


You'll have to muck about with raw AE codes if you want to do it with Scripting Bridge; see past discussions of SB's design flaws for more info.

Actually it's doable in scripting bridge, without any codes. The OP almost had it right when he wrote (or meant to write):


TunesPlaylist *currentPlaylist = [ iTunes currentPlaylist ] ;
SBElementArray *currentTracks = [currentPlaylist tracks];
int index = [currentTracks indexOfObject:[iTunes currentTrack] ] + 1;

The problem is just that indexOfObject: depends on isEqual: being implemented in a meaningful way on the elements of the array, which is not true of the iTunesTrack objects in the currentTracks array. Instead of calling indexOfObjects:, try something like:

    int index = -1;
    int i;

for (i = 0; i < [currentTracks count]; i++) {
if ([[currentTracks objectAtIndex:i] id] == [currentTrack id]) {
index = i + 1;
break;
}
}
// now index is either the index of the track, or -1



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: No track index in iTunes SB? (From: has <email@hidden>)

  • Prev by Date: Button on a button
  • Next by Date: Service without calling app to front?
  • Previous by thread: Re: No track index in iTunes SB?
  • Next by thread: Re: No track index in iTunes SB?
  • Index(es):
    • Date
    • Thread