how do i detect if a text field is full, and if it is full then scroll through it horizontally like on the ipod.
what part of that do i need just for the scrolling, but i’m also doing an itunes controller so how did you make it update the names of the song each time a new song starts
Try this. This wll help you out with your progress bar too.
Create your timing properties
property t1 : 0
property t2 : 0
property t3 : 0
property t4 : 0
property database_ID : missing value
property finish_time : 0
Put this as your on idle handler
on idle theObject
tell application "System Events" to set iTunesRunning to (exists process "iTunes")
if iTunesRunning then
set d_id to missing value
using terms from application "iTunes"
try
tell application "iTunes" to set d_id to database ID of current track
end try
end using terms from
if d_id is not database_ID then tracktext() -- go to tracktext() if the database ID is not the same.
--with 10 seconds of remaining time, it work well if iTunes crossfade Playback is set to 4 seconds or less
if (updateProgress()) > 9 then --update the progress bar, if remaining time is less of 10 seconds then skip the repeat
set t4 to t4 + 1
if t4 > 9 then
repeat with i from 1 to 3
if (item i of {t1, t2, t3}) > 15 then
my scroll_text_in_field(item i of {"title_text", "artist_text", "album_text"})
if (updateProgress()) < 8 then exit repeat --the track will finish, exit the repeat
end if
end repeat
set t4 to 0
end if
else
set t4 to 0
end if
else
quit
end if
return 1
end idle
This method is for updating the progress bar correctly
on updateProgress()
tell application "System Events" to if not (exists process "iTunes") then return 0
using terms from application "iTunes"
tell application "iTunes" to set {sound_volume, track_time} to {sound volume, player position}
end using terms from
if track_time is missing value then
set content of progress indicator "prog_bar" of tab view item "controller_tab" of tab view "my_tab" of window "mainWindow" to 0
tracktext()
return 0
else
set content of progress indicator "prog_bar" of tab view item "controller_tab" of tab view "my_tab" of window "mainWindow" to track_time
return finish_time - track_time
end if
end updateProgress
Here is the method for scrolling the text
on scroll_text_in_field(thename)
tell text field thename of tab view item "controller_tab" of tab view "my_tab" of window "mainWindow"
set the_string to string value
repeat with i from 1 to (count the_string)
set string value to the_string's text i thru -1
delay 0.1
if i mod 10 = 0 then if (my updateProgress()) < 9 then exit repeat --update the progress bar after 1 second
--if remaining time of the current tracks is less of 9 seconds then exit the repeat
end repeat
set string value to the_string
end tell
end scroll_text_in_field
This handles your track info text
on tracktext()
using terms from application "iTunes"
tell application "iTunes"
tell current track to if exists (database ID) then
set {cur_song, cur_artist, cur_album, database_ID, finish_time} to {name as string, artist as string, album as string, database ID, finish}
else
set {cur_song, cur_artist, cur_album, cur_art, database_ID, finish_time} to {"No song", "currently", "playing", missing value, missing value, 100}
end if
end tell
end using terms from
And this is where you tell your window to display all the track info
tell window "main"
set content of text field "title_text" to cur_song
set content of text field "artist_text" to cur_artist
set content of text field "album_text" to cur_album
tell progress indicator "prog_bar" to set {the maximum value, content} to {finish_time, 0}
end tell
set {t1, t2, t3} to {length of cur_song, length of cur_artist, length of cur_album} --set the variables to number of characters
end tracktext
That should work as far as I know, give’r a shot.
the scrolling doesnt work, but everything else does, you just really saved me a lot of time, thanks a lot. but yeah the text isnt scrolling.
EDIT: nevermind we have different text field names, it works now.
lol, i was just about to post a reminder to make sure your objects names matched the code:P
No problem, you can mostly thank Jaques who helped me with most of this a while back.
yeah i was looking through thats thread, i have one more request, how can i get the time elapsed and time remaining and display it in 2 different text fields, like on the ipod (my inferface resembles and ipod)
I’ve actually been trying to figure that out for a while, but I haven’t managed to do it…I’m sure someone here knows how.
P.S. I would like to see some screens of your app, it sounds interesting.
hmm…i know theres something in the itunes dictionary about time remaining and time elapsed but its in seconds.
EDIT: ok i’m uploading some screens now.
EDIT:
the cool thing about it is that you can request permission to control a remote computer’s itunes, and see what they are listening to. and when you roll the mouse over a button it pops out
whoa, thats really cool, did you use custom buttons for like the scroll wheel buttons?
thanks, i used the square button (you know the one in the pallette with the finder icon) and made them transparent.
ah, so you just used rollovers, cool.
figured out how to get remaining time/elapsed time yet? i still wasnt able too. i tried changing the count down example that comes in the dev tools folder but to no avail. if you get it could you show me how?
i havent really been trying, i’m sure if one of us posted a topic about it, we’d get an answer.
sorry to bring up an old topic, but how do i make it so that instead of having the album and artist scroll aswell, i want it to just say as much of the artist/album that will fit then have a … like on the ipod. and just have the title scroll. thanks.
anyone?
just get the length of the text and then if its more than whatever amount truncate the text to replace the last few characters with …
IF you need help with that I suggest you look at the “Now Playing in Adium” applescript. You can get it at http://www.adiumxtras.com/index.php?a=xtras&xtra_id=1563. Go into the package contents and open the Applescript.
but what if the text is much longer than the text field, how would i get the last 3 visible characters?
Did you look at the Adium Script? It does it perfectly