Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Set iChat status message and icon to iTunes song' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set iChat status message and icon to iTunes song
Authored by: ngb on Jul 14, '04 12:33:36AM
You really should close your file, as leaving it open can cause problems if you try to move it, rename it, or delete it. Also, you've got the entire bit about reading the file in your script twice. In the interest clarity and modularity, consider the following:

set myPic to "Willis:Library:Webserver:Documents:me.jpg"
set theMessage to ""
set theData to 0

tell application "iTunes"
    if player state = playing then
        set theMessage to "iTunes:" & artist of current track & " - " & name of current track
        if exists artworks of current track then
            set theData to data of (artwork 1 of current track)
        end if
    end if
end tell

if theData is not 0 then
    set theTiff to giconvert theData type "TIFF" resolution {32, 32}
else
    set r to open for access file myPic
    set theTiff to read r as TIFF picture
    close access r
end if

tell application "iChat"
    set status message to theMessage
    set image to theTiff
end tell
The result is that all the calls to iTunes are together and separate from all the calls to iChat, which are also all together. You'll find code reuse and future editing much easier.

[ Reply to This | # ]
Set iChat status message and icon to iTunes song
Authored by: DaMacGuy on Jul 14, '04 11:24:26PM
So, when I put the path to my prefered image why do I get a file not found error. The following line in ScriptEditor is highlighted...
open for access file myPic

And the path for my default buddy image is...
"cwaldrip:Pictures:me.gif"

I'm assuming (and that could be my problem) that my default buddy image doesn't have to be a jpg like in the example, nor does it need to be in ~/Library/Webserver/.

Am I missing something?

---
-DaMacGuy

[ Reply to This | # ]

Set iChat status message and icon to iTunes song
Authored by: ngb on Jul 15, '04 02:05:13PM
I think the problem is in the path you've defined. You need a full absolute path to the file you wish to open, such as "Macintosh HD:Users:cwaldrip:Pictures:me.gif". In this case I'm assuming that "cwaldrip" is your home directory. You could also use the shortcut path to Pictures folder, but that requires a bit of finessing as demonstrated here:

set picName to "me.gif"
set picPath to path to Pictures folder as text
set f to open for access file (picPath & picName)
close f
It would be really nice to be able to use reference the file as file "me.gif" of (path to Pictures folder), but Applescript chokes on that.

[ Reply to This | # ]
Set iChat status message and icon to iTunes song
Authored by: alajuela on Jul 20, '04 01:43:07PM

Anyone know why this wouldn't work with iTMS song purchases? The Default iChatStatus script recognizes and reports those songs, but this script does not. It is nice on the non-iTMS songs.



[ Reply to This | # ]