|
 |
|
02-26-2007, 09:39 PM
|
#1
|
|
Newbie
Join Date: Dec 2006
Posts: 14
|
Auto-Play iTunes on Wake Up?
Hi. Quick question. Is there any way to have iTunes automatically play when the computer wakes up?
|
|
|
|
|
|
Advertisement
|
Sponsored links
|
02-26-2007, 10:33 PM
|
#2
|
|
Low Bitrate
Join Date: Dec 2005
Posts: 88
|
|
|
|
02-26-2007, 11:51 PM
|
#3
|
|
Variable Bitrate
Join Date: Jan 2007
Location: Dallas
Posts: 365
|
Quote: Originally Posted by timeshifter 
im not sure if any of those scripts will help when just coming out of sleep. the only one there just starts itunes from boot up.
is there any setting to allow or "force" itunes to start playing wherever it left off when put to sleep?
|
|
|
02-27-2007, 01:07 AM
|
#4
|
|
Newbie
Join Date: Dec 2006
Posts: 14
|
yeah thats what im looking to do as well. i could have sworn theres a way to do this with applescript but I havent touched applescript in about 6 or 7 years so Im clueless at this point.
|
|
|
02-27-2007, 08:38 AM
|
#5
|
|
Admin. Don't bug or I'll byte.
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,379
|
There is. I wrote a front end in Applescript and had to solve this problem straight away. However, you have to make the Applescript into an application and have it running all the time.
Use the 'idle handler' which loops each time there are spare cycles on the CPU. Each time you loop, check the status of iTunes. If it is paused, tell it to play.
Of course, the only way to pause iTunes once this app is running is to quit the app or quit iTunes. You can work around it if your app is a frontend or controller for iTunes but I don't think you can if it isn't.
The code is something along these lines (I didn't test it). You can cut and paste it into the Applescript editor, then save it as an application.
on idle
tell application "iTunes"
if player state is paused or player state is stopped then
play
end if
end tell
end idle
***Edit - wait, it's not that simple. I tested it and the idle handler doesn't work. I'll have to investigate further when I have some time***
Last edited by Bugbyte; 02-27-2007 at 09:39 AM.
|
|
|
03-26-2007, 06:35 PM
|
#6
|
|
Variable Bitrate
Join Date: Jan 2007
Location: Dallas
Posts: 365
|
ok so i did some reading up on apple script and i finally got bugbyte's code to work. Here is what you need to do to make this work. in script editior enter in
on idle
tell application "iTunes"
if player state is paused or player state is stopped then
play
end if
end tell
return 1
end idle
when you save this file make sure you save the script as an application and then check the "stay open" box at the bottom of the "save as" window.
if you do everything correctly then you can run this app and it will check every second to see if itunes is paused. i checked it on my system and it seems to work great. if you have any problems pm me and i will see if i can help. thanks bug byte for your help on this.
|
|
|
03-26-2007, 08:07 PM
|
#7
|
|
Constant Bitrate
Join Date: Jul 2006
Location: London
Posts: 129
|
Seems to work fine on the mac indoors, will add in the car tomorrow and test...!
Just need it work within front row to be sure....!
__________________
CLICK ME
Smart Car due for completion beginning of march....
Log with pictures to go online shortly after.
|
|
|
03-27-2007, 12:19 AM
|
#8
|
|
Admin. Don't bug or I'll byte.
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,379
|
Was THAT the problem?! Return 1?!
You know, the on idle loop is a problem. It's not stable. That's the reason we stopped work on our applescript front end. It didn't behave predictably.
|
|
|
|
Sponsored links
|
|
Advertisement
|
|
03-27-2007, 05:57 AM
|
#9
|
|
Constant Bitrate
Join Date: Jul 2006
Location: London
Posts: 129
|
Well, the only problem i can actually see with it at the moment, is the fact that you cannot pause iTunes at all....!
So if you interrupt for a phone call it could cause a problem, is there a work around for the pause to still work...?
__________________
CLICK ME
Smart Car due for completion beginning of march....
Log with pictures to go online shortly after.
|
|
|
03-27-2007, 11:41 AM
|
#10
|
|
Variable Bitrate
Join Date: Jan 2007
Location: Dallas
Posts: 365
|
Quote: Originally Posted by Bugbyte 
Was THAT the problem?! Return 1?!
You know, the on idle loop is a problem. It's not stable. That's the reason we stopped work on our applescript front end. It didn't behave predictably.
yeah actually your code worked you prob just didn't let it run long enough. while i was reading i noticed that the idle handler only checks every 30 seconds or so unless you add the "return" with the number of seconds you want the idle handler to wait before it checks again.
|
|
|
03-27-2007, 12:01 PM
|
#11
|
|
FLAC
Join Date: Aug 2004
Location: Floreeda
Posts: 1,051
|
is there anyway to set a variable to change values when the machine sleeps?
going to sleep changes a variable to a new value.
you could have a script check this variable and if its found at the "slept" variable, it changes it back to normal for the next time, for instance:
var: 1 = machine slept
var: 0 = machine awoke
then it will only apply the pause thing when the var = 1. which only occurs for a millisecond after the machine wakes.
correct me if im wrong.
__________________
(****--) 70.0%
Install commencing.
Mac Mini C2D, RF 600.5 amp, JL10W0V2, 8 Infinity Components
|
|
|
03-27-2007, 12:05 PM
|
#12
|
|
Variable Bitrate
Join Date: Jan 2007
Location: Dallas
Posts: 365
|
this sounds like it would work. once again i am just learning applescript. i wonder if there is actually an event handler that deals with sleep mode. if there is then it is def possible. i will do some checking and see what i can find
|
|
|
03-27-2007, 12:55 PM
|
#13
|
|
Constant Bitrate
Join Date: Jul 2006
Location: London
Posts: 129
|
Sleep isn't an issue, it doesn't wake the machine, but some apps need to shut it by using pause, and if this is running it won;t...
As an example, if you are in front row listening to music, and come out to start a video, it is all good, the film starts the sound comes through, but the music will start again....
__________________
CLICK ME
Smart Car due for completion beginning of march....
Log with pictures to go online shortly after.
|
|
|
03-27-2007, 04:31 PM
|
#14
|
|
Variable Bitrate
Join Date: Jan 2007
Location: Dallas
Posts: 365
|
Quote: Originally Posted by www.workingcars 
Sleep isn't an issue, it doesn't wake the machine, but some apps need to shut it by using pause, and if this is running it won;t...
As an example, if you are in front row listening to music, and come out to start a video, it is all good, the film starts the sound comes through, but the music will start again....
yeah this script was just intended to give a quick solution to ppl using itunes only. one solution for you is to just close the script whenever you need to use another program or use a "quit handler" to automatically quit the script on a certin event, or for your example what i would do is just add on to the script something like this (remember that i am new to applescript and the syntax here may not be correct, i havent had a chance to test this to see if it works or not)
if application "quicktime" (or anyother program you want) is open
then
tell application "itunes"
stop
end tell
end if
i would put this within the idle handler that already exists. this should check to first see if quicktime or something else is open then tell itunes to stop so you could play your movie, but this would also make sure that when you return from sleep that itunes will pickup and start playing
let me know if this works or if you need anything else
*edit - ok so that code is way off. give me some time and i will see if i can figure this out
Last edited by natedawgg; 03-27-2007 at 07:07 PM.
|
|
|
03-27-2007, 05:21 PM
|
#15
|
|
Constant Bitrate
Join Date: Jul 2006
Location: London
Posts: 129
|
I wasn't moaning, it's just that it seems to work well, now it would work even better if in front row it stopped if you went into movies...
I'm not that bothered it is easy enough to quit the script if i want to watch a film... Lol
__________________
CLICK ME
Smart Car due for completion beginning of march....
Log with pictures to go online shortly after.
|
|
|
|
Sponsored links
|
|
Advertisement
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:26 PM.
| |