Hi guys, I found this two AppleScripts, one of them is to gradually increase the volume in iTunes, and it looks like this:
property tick : 5 – raise volume level by this many each loop
property thismany : 2 – seconds to wait before making next increment to volume
tell application “iTunes”
set sound volume to 100
set snd to sound volume
set sound volume to 0
play playlist “Party Shuffle” – your playlist here
repeat
if (get sound volume) is greater than or equal to (snd - tick) then
set sound volume to snd
exit repeat
end if
set sound volume to (sound volume + tick)
delay thismany
end repeat
end tell
The other one plays a random song from Party Shuffle and it looks like this:
set volume of 7
tell application “iTunes”
activate
tell source “Library”
tell playlist “Party Shuffle”
set randomtrack to some track
play randomtrack
end tell
end tell
end tell
What I’m trying to do is to combine these two AppleScripts so I can be able to listen to a random song from Party Shuffle, and gradually increase the volume.
Maybe is something simple but I have been trying and trying to make it work without success since I’m new to AppleScript.
Any help will be appreciated.
-hugomagic
Model: PowerBook G4
AppleScript: 1.9.3
Browser: Safari 312.3
Operating System: Mac OS X (10.3.9)
Model: PowerBook G4
AppleScript: 1.9.3
Browser: Safari 312.3
Operating System: Mac OS X (10.3.9)
Model: PowerBook G4
AppleScript: 1.9.3
Browser: Safari 312.3
Operating System: Mac OS X (10.3.9)
property tick : 5 -- raise volume level by this many each loop
property thismany : 2 -- seconds to wait before making next increment to volume
set maxVol to 100 -- maximum volume level
tell application "iTunes"
set sound volume to 0
play some track of playlist "Party Shuffle" -- your playlist here
repeat with currVol from 0 to maxVol by tick
set sound volume to currVol
delay thismany
end repeat
if currVol < maxVol then set sound volume to maxVol
end tell
This appears to be a bug in the new iTunes. For some reason you can’t set sound volume to x, but you can copy x to sound volume. Too funny. I’ll followup with a script.
update: Found out this is actually a terminology conflict with Jon’s Commands scripting addition. The “copy to” form won’t hurt anything though.
Edit: As already mentioned, the problem was evidently down to a conflict with Jon’s - so…
property tick : 5 -- raise volume level by this many each loop
property thismany : 2 -- seconds to wait before making next increment to volume
set maxVol to 100 -- maximum volume level
tell application "iTunes"
set (sound volume) to 0
play some track of playlist "Party Shuffle" -- your playlist here
repeat with currVol from 0 to maxVol by tick
set (sound volume) to currVol
delay thismany
end repeat
if currVol < maxVol then set (sound volume) to maxVol
end tell
Okay, so as noted above after keenly observing the lack of a boldface set command in the compiled script, I pegged this as a scripting addition conflict. I don’t know if this is what was keeping your script from functioning, but in my case the culprit was Jon’s Commands. Anywho, the conflict is easily resolved with parenthesis:
tell application "iTunes" to set (sound volume) to 50
I wasn’t experiencing a problem here, silvermeteors - but then I try to keep Jon’s out of the mix when scripting generally. (Still sometimes forget to remove it, though - and get my fingers burned as a result!)
Since I was working with a slightly dated version of iTunes at the time, I took your comment about the latest version at face value - and just amended my script accordingly. However, there is a need to cover the possibility of Jon’s being present on a machine - and I’d go for parens, too. (I’ve edited the above script accordingly.)