Sponsored links

Go Back   MP3Car.com > Mp3Car Technical > MacCar


Reply
 
Share Thread Tools Display Modes
Old 03-27-2007, 05:41 PM   #16
Constant Bitrate
 
Join Date: Feb 2006
Posts: 125
skiman is on a distinguished road
Alarm Clock 2 i use this as my alarm clock and its GREAT. alarm clock 2. it uses itunes library and playlists and stuff but i dont think itunes has to be open but i may be wrong.
skiman is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Old 03-27-2007, 06:18 PM   #17
Variable Bitrate
 
natedawgg's Avatar
 
Join Date: Jan 2007
Location: Dallas
Posts: 335
natedawgg is an unknown quantity at this point
thats cool. but try that last bit of code and see if that helps your situation. let me know if it does
natedawgg is offline   Reply With Quote
Old 03-27-2007, 06:28 PM   #18
Newbie
 
Count_Fred's Avatar
 
Join Date: Sep 2006
Location: Lynnwood, WA
Posts: 2
Count_Fred is an unknown quantity at this point
I use SleepWatcher (bb's Homepage ) to run various Applescripts at sleep and wake. One of them is to start iTunes playing.


BugByte: Can you say more about how the idle loop is unstable? I'm about to start using it to pull values off an Arduino (microcontroller board) and haven't had any problems with the code on my test machine so far. Perhaps the instability will show up when I transfer the new code to the mini in the car.

Cheers,
JFS III
Count_Fred is offline   Reply With Quote
Old 03-27-2007, 07:26 PM   #19
Admin. Don't bug or I'll byte.
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,142
Bugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to behold
Quote: Originally Posted by Count_Fred View Post
BugByte: Can you say more about how the idle loop is unstable? I'm about to start using it to pull values off an Arduino (microcontroller board) and haven't had any problems with the code on my test machine so far.

Well, it becomes a problem when you have a full featured app programmed. What sealed it for us was that when you clicked a button on the screen, it would light up to show clicked, but it would never un-click. Until you pressed it a SECOND time.

The way we had it set up, the idle handler was what got called whenever you pressed a button and then routed the action off to the proper script depending on what screen was displayed. This allowed us to reuse buttons from screen to screen and so forth.

In any case, the idle handler makes it difficult to debug the script because it fires whenever it has time -sometimes in the middle of one of your other scripts running. So the debugger will be following through some code you're trying to debug and then shoots you off to the idle handler over and over. Makes it difficult to debug.

As for the sleep/wake problem, we did solve that pretty easily. You have to program the script as an application. That allows you to read and write preferences. Once you can do that, you can set those prefs according to what's going on with the various apps on the screen or inputs from the keyboard.

We had the same issue of not being able to pause iTunes. You get around it by setting a preference when you click a button onscreen or get some keyboard input. Your application 'sets' that preference to pause, then pauses iTunes. Next time through, you compare the application's pause pref with the iTunes state. If they are BOTH pause, then you stay paused.

Then, when you click the button or hit the key, you set the app's pref to 'play' and next time through, the idle handler compares that to the iTunes state, which is paused. It starts iTunes playing at that point.

I don't think you can read/write pref files through the script editor, although I could be wrong. You have to use XCode to build an applescript application.
__________________
Want to:
-Find out about the iBug?
-Stop being a newbie? Take a look at the FAQ Emporium?
-Find out about carPC's in just 5 minutes? View the Car PC 101 video
-Help me kill my car PC
-Watch live video streams from my mobile PC? Check it out here.
-Where is the iBug?
Bugbyte is offline   Reply With Quote
Old 04-30-2007, 11:48 PM   #20
Variable Bitrate
 
natedawgg's Avatar
 
Join Date: Jan 2007
Location: Dallas
Posts: 335
natedawgg is an unknown quantity at this point
ok everybody here is a script that i edited to help make itunes a bit more managable in the car. due to a battery issue that i have yet to fix in my car, my mac keeps shutting down instead of sleep so i did some searching and came up with this script and edited it a little. this script helps in the event of a reboot or whatever else that causes itunes to shutdown. it will keep an eye on what song you are currently listening to and then when and if itunes is shutdown it will start it back up playing the same song as before.

ok here it is:

property Song_To_Start : 1
property Plist_To_Start : "Library"

on idle
tell application "iTunes"
if player state is paused then
play
else if player state is playing then
copy (name of container of current track) to Plist_To_Start
copy index of current track to Song_To_Start
else if player state is stopped then
play track Song_To_Start of playlist Plist_To_Start
end if
end tell
return 1
end idle

ok now as before make sure that you save it as an application and that the "stay open" box is checked.

im not a 100% sure that all the bugs are fixed so be forwarned. hope this helps some.
natedawgg is offline   Reply With Quote
Old 05-02-2007, 05:39 PM   #21
Admin. Don't bug or I'll byte.
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,142
Bugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to behold
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.
__________________
Want to:
-Find out about the iBug?
-Stop being a newbie? Take a look at the FAQ Emporium?
-Find out about carPC's in just 5 minutes? View the Car PC 101 video
-Help me kill my car PC
-Watch live video streams from my mobile PC? Check it out here.
-Where is the iBug?
Bugbyte is offline   Reply With Quote
Old 05-02-2007, 08:06 PM   #22
Variable Bitrate
 
natedawgg's Avatar
 
Join Date: Jan 2007
Location: Dallas
Posts: 335
natedawgg is an unknown quantity at this point
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
natedawgg is offline   Reply With Quote
Old 05-02-2007, 09:19 PM   #23
Admin. Don't bug or I'll byte.
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,142
Bugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to behold
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.
__________________
Want to:
-Find out about the iBug?
-Stop being a newbie? Take a look at the FAQ Emporium?
-Find out about carPC's in just 5 minutes? View the Car PC 101 video
-Help me kill my car PC
-Watch live video streams from my mobile PC? Check it out here.
-Where is the iBug?
Bugbyte is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Old 05-09-2007, 01:29 AM   #24
Variable Bitrate
 
natedawgg's Avatar
 
Join Date: Jan 2007
Location: Dallas
Posts: 335
natedawgg is an unknown quantity at this point
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.
natedawgg is offline   Reply With Quote
Old 04-21-2008, 08:14 PM   #25
Newbie
 
Join Date: Apr 2008
Posts: 2
dacomputernerd is an unknown quantity at this point
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.
dacomputernerd is offline   Reply With Quote
Old 04-22-2008, 01:43 AM   #26
Admin. Don't bug or I'll byte.
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,142
Bugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to behold
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!
__________________
Want to:
-Find out about the iBug?
-Stop being a newbie? Take a look at the FAQ Emporium?
-Find out about carPC's in just 5 minutes? View the Car PC 101 video
-Help me kill my car PC
-Watch live video streams from my mobile PC? Check it out here.
-Where is the iBug?
Bugbyte is offline   Reply With Quote
Old 04-22-2008, 05:00 AM   #27
QCar Creator
 
Jirka Jirout's Avatar
 
Join Date: Jul 2005
Location: Netherlands
Posts: 577
Jirka Jirout is on a distinguished road
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.
Jirka Jirout is offline   Reply With Quote
Old 04-22-2008, 01:05 PM   #28
Admin. Don't bug or I'll byte.
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,142
Bugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to behold
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.
__________________
Want to:
-Find out about the iBug?
-Stop being a newbie? Take a look at the FAQ Emporium?
-Find out about carPC's in just 5 minutes? View the Car PC 101 video
-Help me kill my car PC
-Watch live video streams from my mobile PC? Check it out here.
-Where is the iBug?
Bugbyte is offline   Reply With Quote
Old 04-22-2008, 04:52 PM   #29
Newbie
 
Join Date: Apr 2008
Posts: 2
dacomputernerd is an unknown quantity at this point
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.
dacomputernerd is offline   Reply With Quote
Old 04-22-2008, 06:04 PM   #30
Admin. Don't bug or I'll byte.
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Posts: 6,142
Bugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to beholdBugbyte is a splendid one to behold
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.
__________________
Want to:
-Find out about the iBug?
-Stop being a newbie? Take a look at the FAQ Emporium?
-Find out about carPC's in just 5 minutes? View the Car PC 101 video
-Help me kill my car PC
-Watch live video streams from my mobile PC? Check it out here.
-Where is the iBug?
Bugbyte is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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



All times are GMT -5. The time now is 08:05 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics