Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

Thread: Auto-Play iTunes on Wake Up?

  1. #21
    Admin. Linux loser.
    Auto Apps:loading...
    Bugbyte's Avatar
    Join Date
    Sep 2004
    Location
    Corning, NY
    Posts
    7,359
    Blog Entries
    2
    Does that take advantage of the Applescript feature that it 'remembers' the state when you run it, even if you quit the app and restart it?

    If so, cool. Nice use of that feature.
    Quote Originally Posted by ghettocruzer View Post
    I was gung ho on building a PC [until] just recently. However, between my new phone having internet and GPS and all...and this kit...Im starting to have trouble justfiying it haha.
    Want to:
    -Find out about the new iBug iPad install?
    -Find out about carPC's in just 5 minutes? View the Car PC 101 video

  2. #22
    Variable Bitrate natedawgg's Avatar
    Join Date
    Jan 2007
    Location
    Dallas
    Posts
    365
    yeah it does. the whole reason i wrote the script is because my mini keeps shutting down instead of sleeping (bad battery) and i got tired of having to find the cd that i was playing previously. i think there are still some bugs that i need to work out. so i will continue on with it and post back with any updates

  3. #23
    Admin. Linux loser.
    Auto Apps:loading...
    Bugbyte's Avatar
    Join Date
    Sep 2004
    Location
    Corning, NY
    Posts
    7,359
    Blog Entries
    2
    Good one. How about adding a variable that keeps track of the player head position:

    property Track_position: 1

    Then use:

    copy player position to Track_position

    to keep track of where in the song it was and set the player position back to that spot if you reboot.
    Quote Originally Posted by ghettocruzer View Post
    I was gung ho on building a PC [until] just recently. However, between my new phone having internet and GPS and all...and this kit...Im starting to have trouble justfiying it haha.
    Want to:
    -Find out about the new iBug iPad install?
    -Find out about carPC's in just 5 minutes? View the Car PC 101 video

  4. #24
    Variable Bitrate natedawgg's Avatar
    Join Date
    Jan 2007
    Location
    Dallas
    Posts
    365
    Bugbyte, i have a quick question regarding the behavior of applescript. i have had a week or so now to use and test the script that i posted earlier in this thread, and i have come to notice 2 main bugs to which i don't know how to go about fixing.

    the first is when the mini reboots the variables are i guess set to whatever, cause after the boot, itunes launches and a song starts playing. it seems to be just some random song, but now everytime that it reboots it plays that song. now if i am just running itunes listening to music, and i shut down itunes or the script, itunes will restart and resume playing the song that it left off just like it should. so my question is if there is a way to make applescript write the song info to an actual file that is on the harddrive vs ram and then be able to get the song info from that file? because i think it is the ram being cleared during the reboot.

    the second issue is that the app keeps timing out. do you know how to work around this?

    thanks for any help you can give.

  5. #25
    Newbie dacomputernerd's Avatar
    Join Date
    Apr 2008
    Posts
    7
    Quote Originally Posted by natedawgg View Post
    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.
    Would It be possible to modify this script so that it would work with:

    Quote Originally Posted by Count_Fred View Post
    I use SleepWatcher (bb's Homepage ) to run various Applescripts at sleep and wake. One of them is to start iTunes playing.
    Maybe replace "on idle" with "on wake" or something? IDK anything about this stuff though.

  6. #26
    Admin. Linux loser.
    Auto Apps:loading...
    Bugbyte's Avatar
    Join Date
    Sep 2004
    Location
    Corning, NY
    Posts
    7,359
    Blog Entries
    2
    There is no 'on wake' in Applescript. On Idle tells the script to perform the commands that follow when it has a spare moment and causes it to keep looping.

    If you are sleeping the Mini, the script should suspend until you wake the Mini, so no need for the Sleepwatcher solution.

    @Natedawgg - I never saw your question, but that is how Applescript works. It stores the last state that it was shut down in the variables. Very odd behavior. It is possible to read and write plist variables using applescript to keep track of what song and what track position iTunes is on from moment to moment, but I presume since you are writing your own FE now, this isn't a concern anymore!
    Quote Originally Posted by ghettocruzer View Post
    I was gung ho on building a PC [until] just recently. However, between my new phone having internet and GPS and all...and this kit...Im starting to have trouble justfiying it haha.
    Want to:
    -Find out about the new iBug iPad install?
    -Find out about carPC's in just 5 minutes? View the Car PC 101 video

  7. #27
    QCar Creator Jirka Jirout's Avatar
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    590
    Quote Originally Posted by Bugbyte View Post
    ...that is how Applescript works. It stores the last state that it was shut down in the variables. Very odd behavior. ...
    I am not 100% sure, but I believe only the contents of the properties (explicitly declared by property keyword) is preserved, not regular variables.

  8. #28
    Admin. Linux loser.
    Auto Apps:loading...
    Bugbyte's Avatar
    Join Date
    Sep 2004
    Location
    Corning, NY
    Posts
    7,359
    Blog Entries
    2
    Jirka is right - again. According to my "Applescript - The Definitive Guide" (which I highly recommend if you want to do anything in AS), scripting components have a memory, or rather, they maintain state. Internal memory of an AppleScript scripting component persists until the application that summoned it quits.

    However, variables declared using the property keyword survive the termination of the script.

    Try this script to see what I mean:

    property x :5
    set x to x + 1
    display dialog x

    Run it and you'll get 6. Run it again and you'll get 7. Doesn't matter that you initialize x to 5 at the start because the property keyword sets a value to a variable that doesn't have a value. Which is why it works the first time. The second time, x already has a value (6), so it doesn't need initializing.

    Use the 'set' keyword to both initialize AND set the value you want.

    set x to 5
    set x to x + 1
    display dialog x

    Will yield 6 over and over again.

    BTW, if you edit the script in Script Editor between runs, you won't get this result. That's because you have altered the script and it has to be recompiled. But if you save the first script as a compiled script file and quit Script Editor, then launch and relaunch your compiled script, you'll see what I mean.

    I believe that restarting the machine will wipe the variable persistence and start you back at the original value.

    I find it is best to just use 'set' to keep things Kosher. Again, if you want to set plist variables, let me know and I'll post the code.
    Quote Originally Posted by ghettocruzer View Post
    I was gung ho on building a PC [until] just recently. However, between my new phone having internet and GPS and all...and this kit...Im starting to have trouble justfiying it haha.
    Want to:
    -Find out about the new iBug iPad install?
    -Find out about carPC's in just 5 minutes? View the Car PC 101 video

  9. #29
    Newbie dacomputernerd's Avatar
    Join Date
    Apr 2008
    Posts
    7
    Quote Originally Posted by Bugbyte View Post
    If you are sleeping the Mini, the script should suspend until you wake the Mini, so no need for the Sleepwatcher solution.
    I'm not using this on a mini however. I'm using it on my Macbook pro. When i open it (it wakes) I want it to start playing where it left off with iTunes.

    Also i want to be able to manually pause and stop it without closing the script.

  10. #30
    Admin. Linux loser.
    Auto Apps:loading...
    Bugbyte's Avatar
    Join Date
    Sep 2004
    Location
    Corning, NY
    Posts
    7,359
    Blog Entries
    2
    Are you saying that when you run this script and the machine wakes up that it doesn't start iTunes? It should, as long as the script is running.

    To manually pause and stop, you have to add code to read and write prefs. Effectively, you have to toggle a pref in response to a key command or on screen button press. Then, you have to check both the iTunes state AND the pref state. If the pref state says you pushed a pause key/button, it drops out of the script. When you toggle that pref again, it restarts iTunes.
    Quote Originally Posted by ghettocruzer View Post
    I was gung ho on building a PC [until] just recently. However, between my new phone having internet and GPS and all...and this kit...Im starting to have trouble justfiying it haha.
    Want to:
    -Find out about the new iBug iPad install?
    -Find out about carPC's in just 5 minutes? View the Car PC 101 video

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Auto Disconnect From Cell Phone Without Delay......Is This Possible?
    By jmciver in forum Wireless Communications
    Replies: 0
    Last Post: 12-16-2006, 01:56 PM
  2. Skin and auto play bug...
    By the_tiger in forum CF Bug Reports
    Replies: 0
    Last Post: 10-05-2006, 12:52 PM
  3. Winamp doesn't play, but the play sign is there
    By mbowler in forum Software & Software Development
    Replies: 0
    Last Post: 08-03-2000, 07:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •