Saturday, December 16, 2017

#1 2017-09-12 06:44:36 am

Riku
Member
Registered: 2016-05-23
Posts: 27

Repairing the scripts that the new iTunes version broke (again)?

I'm on Yosemite and not planning to upgrade further.
I have been avoiding updating iTunes as well because since version 12, it changed into something unbelievably difficult to use, jumpy, unpractical and ugly. Recently some native Apple apps were acting up by having their UIs disappear completely, and some sub-menu use problems, so I'd have to restart the application and start over. iTunes was among the bugged ones and I thought, okay, I don't think it can change too much anymore can it, I updated to version 12.6.2.20 and – how textbook – my iTunes scripts are broken, again.

This is where it fails:

Applescript:

---Select and Play Playlist in iTunes
tell application "iTunes"
   set «class pMin» of front browser window to false
   set view of front browser window to playlist "Playlist name"
   set sound volume to 100
   play playlist "Playlist name"
end tell
---Toggle Shuffle On
tell application "System Events"
   tell process "iTunes" to if exists then
       click menu item "On" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar 1
       delay 5
       tell application "iTunes"
           set «class pMin» of front browser window to true
       end tell
       
   end if
end tell

It's having problems with the object «class pMin», how do I talk to the new iTunes then?
I must admit, I have been so angry about the iTunes versions since 12, I might eventually take time to investigate how to downgrade way back and see if it works, but for now, I'd just like to restore what they keep breaking.


Filed under: iTunes, playlist, shuffle

Offline

 

#2 2017-09-12 08:31:06 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3203

Re: Repairing the scripts that the new iTunes version broke (again)?

If my memory is right, you missed a step in the click instruction.


Applescript:

click menu item "On" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1

ways if my

According to Script Debugger, the standard syntax for the instruction using «class pMin" is :

Applescript:

set type parameter info of front browser window to false

It's the command whose shortcut is shift + cmd + M available in the menu Window.

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mardi 12 septembre 2017 15:31:00

Offline

 

#3 2017-09-12 11:45:17 am

Riku
Member
Registered: 2016-05-23
Posts: 27

Re: Repairing the scripts that the new iTunes version broke (again)?

I replaced

set «class pMin» of front browser window to false

and its true counterpart with :

Yvan Koenig wrote:

set type parameter info of front browser window to false


and its true counterpart but the script still fails at the same line, highlighting it and coming up with

"error "iTunes got an error: Unknown object type." number -1731"


Did I miss something?



I replaced the click phase with what you suggested, too, but I don't know if it works because the script can't get over the browser window line and, the click phase actually used to work just fine up until now, I've only had an error message referring of the «class pMin» term.

Last edited by Riku (2017-09-12 11:46:46 am)

Offline

 

#4 2017-09-13 02:11:02 pm

Riku
Member
Registered: 2016-05-23
Posts: 27

Re: Repairing the scripts that the new iTunes version broke (again)?

Okay I managed to play around a little... The terms have changed. I didn't manage to find out how to minimize the window so because "frontmost to false" doesn't do the trick so I just emulated cmd+m. If I run this as an application, it does what it says on the tin.

Applescript:


---This piece of script was made to work in iTunes 12.6.2.20.
---This script Plays Playlist in iTunes on shuffle at full app volume, then minimizes it.
tell application "iTunes"
   set frontmost to true
   delay 3 --because if iTunes has to be launched, it has to load the library fully before commands
   set sound volume to 100 --because it might have been left at some other level
   set view of front browser window to playlist "Playlist Name" ---to address the next command to a specific playlist
set shuffle enabled to true ---to apply shuffle to that playlist
   play playlist "Playlist Name"
end tell
tell application "System Events"
   tell process "iTunes" to if exists then
       tell application "iTunes"
           set frontmost to true
       end tell
       tell application "System Events" to key code 46 using command down --cmd+M to minimize
   end if
end tell

Last edited by Riku (2017-09-13 02:14:51 pm)


Filed under: iTunes, play, playlist, shuffle

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)