• 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: Christopher Nebel <email@hidden>
  • Date: Mon, 10 Mar 2008 12:04:20 -0700

On Mar 10, 2008, at 4:56 AM, email@hidden 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?

What's missing is the line in iTunes' dictionary that says that tracks have an "index" property in the first place. Scripting Bridge takes the dictionary at its word, and therefore, no -[iTunesTrack index] accessor. Ultimately, it's an iTunes bug. In the meantime, you can work around the problem by using the raw codes [1]:


int index = [[[[iTunes currentTrack] propertyWithCode:'pidx'] get] intValue];

Ordinarily, Scripting Bridge would take care of the -get and -intValue for you, since this is an attribute you're dealing with [2], but if you're dropping down to the base level, you have to be explicit.


--Chris Nebel AppleScript Engineering

[1] You can find the raw code by inspecting the dictionary. For spot queries like this, I find it easiest to use Terminal:

% sdef /Applications/iTunes.app | xmllint --format - | grep 'name="index"'
<property name="index" code="pidx" type="integer" access="r" description="the index of the playlist in internal application order"/>


[2] This is covered in the documentation under "Lazy Evaluation": when you use an accessor that returns an attribute (in other words, anything that isn't an SBObject descendant or SBElementArray), Scripting Bridge will automatically do a -get and unbox the value for you.
_______________________________________________


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


  • Follow-Ups:
    • Re: No track index in iTunes SB?
      • From: email@hidden
References: 
 >No track index in iTunes SB? (From: email@hidden)

  • Prev by Date: Re: fileExistsAtPath with * to indicate random
  • Next by Date: Re: fileExistsAtPath with * to indicate random
  • Previous by thread: Re: No track index in iTunes SB?
  • Next by thread: Re: No track index in iTunes SB?
  • Index(es):
    • Date
    • Thread