Playing One Tune Once?
You could do it in SoundJam, but not in iTunes. Not without having to create a one-tune playlist each time, or babysitting the computer to stop iTunes after the one selection plays once. Ridiculous. Some "digital hub." Bah.
I wonder, is there a way of achieving "one tune once" via AS? Thx.
[299 byte] By [
rogerwilco] at [2007-11-9 13:29:52]

# 1 Re: Playing One Tune Once?
You could create Stay-open applet that stopped iTunes after playing the selected song. But, by the time the thing got up and running, you may have lost your desire to hear the song.
Try this, down and dirty compiled thang:
tell application "iTunes"
if (count of items of selection) is 1 then
play item 1 of selection
delay (get finish of item 1 of selection) - 1
stop
end if
end tell
Not the greatest script ever, but it'll play the one selected song and stop.
# 2 Re: Playing One Tune Once?
Doug,
It works but it freezes the whole iTunes window while playing that one tune. No buttons work. Progress bar is stuck at the start and text is static. Any way to refine things a bit?
Thx.
# 3 Re: Playing One Tune Once?
Any way to refine things a bit?
tell application "iTunes"
if (count of items of selection) is 1 then
play item 1 of selection
delay (get finish of item 1 of selection) - 1
stop
end if
end tell
quit
Save it as an "application" in Script Editor (note the addition of "quit" at the bottom). It will run "outside" of iTunes and won't freeze you out. It will take a few moments for it to get started as an app, however. Perhaps that's not a big deal.
# 4 Re: Playing One Tune Once?
I've posted a finished version of this script under the name Just Play This One ( http://www.malcolmadams.com/itunes/scripts/scripts02.shtml#justplaythisone).
# 5 Re: Playing One Tune Once?
Doh! I didn't remember to tell you I basically use the Library list, not a playlist. I tried it, and the window freezing problem is gone. However, after choosing one selection from the Library list and running the script/app, iTunes does not stop playing after that one but moves on down the list as before. Any way to save my dream...?
# 6 Re: Playing One Tune Once?
It should stop iTunes, even if a successive song just starts to play...when run as an app, that is.
# 7 Re: Playing One Tune Once?
Run as an app, the script, as it were, is nevertheless unable to stop iTunes from playing the next consecutive tune when working in the Library list.
No problems at all in any other playlist though, which is a great big step up in my iTunes user experience, for sure.
I wish I understood enough about these things to figure out why what works for a Playlist doesn't work for the Library. Aargh.
# 8 Re: Playing One Tune Once?
That's odd. I have no troubles with the script no matter where I select the song from. How many tracks are in your main library, just out of curiosity?
# 9 Re: Playing One Tune Once?
At the moment, 856 selections. Does it matter that I'm still using iTunes 4.0?
# 10 Re: Playing One Tune Once?
No, actually, nothing should stop it from stopping :D It delays for the length of the song and then tells iTunes to stop, so no matter what iTunes is doing, even if you skipped ahead or back or started playing another track, the script would still tell iTunes to stop after the length of the selected track had been reached. Odd.
# 11 Re: Playing One Tune Once?
Well, I updated to iTunes 4.01 and tried the script yet again. Now it works, in fact it works as long as I do nothing. If, however, for instance, I skip forward in the selection I'm playing, and then wait til it ends, the next consecutive tune begins playing (the script is still active and shows up in the Dock) but then suddenly quits 2.5 mins into it when the script finally quits.
Something is keeping the script from quitting at the end of the chosen selection if I do anything to disturb the progress bar. Bizarre. BTW I've been using the "Remaining time" setting on the timer. Could that....? Just tried it using Elapsed. This time the next selection quit about 30 sec into it. So, it seems that there is something going on depending on whether Remaining or Elapsed is chosen for the timer. But what might keep this app/script from quitting on time?
:rolleyes:
Aha! I just tried it using the static Total Time setting. This way it works exactly the way you meant. Thank you for your remarkable patience and help with this problem of mine.
:D
