|
#1
| ||||
| ||||
|
well, slightly more complicated than that: I have written two applescripts, one that is executed just before system sleep the other when the system wakes. The first checks if itunes is running and if it is playing. The second then resumes playing if itunes was playing before sleep.(notice the classy fade in) on sleep: itunesSleep.scpt Code: try do shell script "top -l 1 | grep 'iTunes'" tell application "iTunes" if player state as string is "playing" then do shell script "/bin/echo play >~/itunesStatus.txt" end tell end try Code: try tell application "iTunes" do shell script "/bin/cat ~/itunesStatus.txt" set stat to result as string set vol to sound volume as number set sound volume to 0 if stat is "play" then play repeat with i from 1 to vol set sound volume to i set i to i + 1 delay 0.4 end repeat do shell script "/bin/rm ~/itunesStatus.txt" end tell end try osascript -l Applescript itunesSleep.scpt it packs a sad and fails to write the itunesStatus.txt file because the player status is <<constant ****kPSP>> when run from terminal no matter what state the player is actually in. Anyone have any ideas as to what is going on?? By the way i am planning on using sleepwatcher to run the scripts, but it can only run unix scripts, hence the need to use osascript. Cheers.
__________________ | PowerBook G4 550 - 10.4 - 512Mb - 20Gb | 30Gb iPod Photo | 40x12x48 Fantom Drives CDRW (firewire) | Logitech Cordless Mouse MX700 | xBox with XBMC for movies and music in the lounge |
|
#2
| ||||
| ||||
|
someone?
__________________ | PowerBook G4 550 - 10.4 - 512Mb - 20Gb | 30Gb iPod Photo | 40x12x48 Fantom Drives CDRW (firewire) | Logitech Cordless Mouse MX700 | xBox with XBMC for movies and music in the lounge |
|
#3
| ||||
| ||||
|
Is there anybody out there (PF)... Tried it myself. Same problem. Looked on the ol' internet. Don't use string! playing is a usable constant. I changed the check routine to look for "playing". And I put a dot in front of the status file name. tell application "iTunes" if player state is playing then do shell script "/bin/echo playing >~/.itunesStatus.txt" else do shell script "/bin/echo stopped >~/.itunesStatus.txt" end if end tell
__________________ Jove Talk doesn't cook rice. Last edited by jove; March 17th, 2003 at 12:13 AM. |
|
#4
| ||||
| ||||
|
The scripts work flawlessly. Sleep and wakeup do not. The scripts are saved as applications in ~/Library/scripts. The .wakeup and .sleep scripts call "open ~/Library/Scripts/..." The sleep application doesn't perform until wakeup. The wakeup application doesn't perform until a couple seconds later! We need to be able to tell the system "Don't sleep until Applescript is done".
__________________ Jove Talk doesn't cook rice. |
|
#5
| ||||
| ||||
|
i have given up on getting the playing status of itunes before sleep, instead i just execute one script on wake up Code: tell application "Finder"
if processes contains {process "iTunes"} then
-- iTunes is running
tell application "iTunes"
set vol to sound volume as number
set sound volume to 0
back track
play
repeat with i from 1 to vol
set sound volume to i
set i to i + 1
delay 0.4
end repeat
end tell
end if
end tell
%osascript scriptname.scpt dont forget to "chomd +x" your shell script file This works perfectly for me. on another note i often play my mac into a stereo so i find this script comes in handy: Code: tell application "Dock"
activate
display dialog "Choose Volume setting" buttons {"Stereo", "Normal"} default button 2
set var to the button returned of the result
if var is "Stereo" then
tell application "iTunes"
back track
play
set sound volume to 100
set volume 10
end tell
else
tell application "iTunes"
next track
play
set sound volume to 15
set volume 1
end tell
end if
end tell
An improvement to this script would be to get the system volume and check if full volume change to min volume, and visa versa
__________________ | PowerBook G4 550 - 10.4 - 512Mb - 20Gb | 30Gb iPod Photo | 40x12x48 Fantom Drives CDRW (firewire) | Logitech Cordless Mouse MX700 | xBox with XBMC for movies and music in the lounge |
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [HOW TO] Autoplay itunes on wake | profx | HOWTO & FAQs | 1 | March 6th, 2003 06:03 PM |
| important iTunes install info | zootbobbalu | Apple News, Rumors & Discussion | 15 | July 19th, 2002 12:18 AM |
| iTunes 2 is going nuts! Bloated Temp Files! | GadgetLover | Mac OS X System & Mac Software | 8 | April 11th, 2002 05:45 PM |
| AppleScript, iTunes, Mp3 Tags, idea and problem | jove | Software Programming & Web Scripting | 0 | March 11th, 2002 05:03 PM |
| AppleScript to find iTunes songs with no Playlist | rharder | Apple News, Rumors & Discussion | 0 | December 29th, 2001 11:27 AM |