I’m using this example as a basis and would love to retrieve a bit more information about the current track. For instance, what the current time of the track is (where the “playhead” is) and what the total track length is.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to get into using Python and AppleEvent scripting, I would strongly urge you to use
py-appscriptrather than Scripting Bridge. appscript is robust and well-maintained by its independent developer, whereas Scripting Bridge does not seem to be high on the radar anymore at Apple.py-appscriptis also supported on both Python 2 and Python 3.You can the ASDictionary tool provided by
appscriptto explore the scripting dictionaries provided by scriptable applications. Or you can view the dictionary in Apple’sAppleScript Editor.app(previously known asScript Editor) and manually translate the syntax. In this case, after installingpy-appscriptin one of your Python instances, it is pretty easy. In the scripting dictionary definition for iTunes, there are various properties listed for theapplicationobject. One listed is:player position (integer) : the player’s position within the currently playing track in seconds.
Another is:
player state (stopped/playing/paused/fast forwarding/rewinding, r/o) : is iTunes stopped, paused, or playing?
To make valid Python names,
py-appscriptautomatically replaces any space characters with an underscore character: