iTunes can't connect to shared library UNLESS it's manually connected?

this is a problem i've been monkeying with off and on for nearly a year now, but haven't ever found a solution for.

What I am specifically looking for is a way to connect to a shared library on my local network but do so without having to physically click the library to connect it. Everything that I've found has worked after the library has been connected, but I can't find a solution that actually connects to the library.

I've asked doug at doug's applescripts for help... he had no answer.
i've asked hanaan rosenthal (author of a few applescript books) for help.. he had no answer.
i've posted a few times on macscripter.net ( http://macscripter.net/viewtopic.php?id=35511 ) ... nobody had an answer.
i've dug around the apple discussion boards ( http://discussions.apple.com/thread.jspa?threadID=2324452) and found similar questions, but there were no satisfactory answers...

both of the following scripts work when the library is already connected but fail when it's not... how can i get it to work every time...

activate application "iTunes"
tell application "System Events"
tell process "iTunes"
get the value of static text 1 of row 17 of outline 1 of scroll area 2 of window 1
end tell
end tell

tell application "iTunes"
activate
repeat with theSource in every source
if name of theSource as text is "MY SHARED LIBRARY" then
set theLibrary to user playlist "MY SHARED PLAYLIST" of theSource
end if
end repeat
tell theLibrary
set shuffle to true
set song repeat to all
end tell
play some track of theLibrary
end tell

any help would be very much appreciated.

iMac 27", Mac OS X (10.6.7), iTunes 10.2

Posted on Apr 14, 2011 4:27 PM

Reply
3 replies

Apr 15, 2011 2:43 AM in response to ichbinglitched

Hi,

This script works well here.


tell application "iTunes"
activate
tell front browser window to if minimized then set minimized to false
if my connectSource() then repeat 12 times
tell source "MY SHARED LIBRARY" to if exists then
tell user playlist "MY SHARED PLAYLIST" to if exists then
set shuffle to true
set song repeat to all
play some track
return
end if
end if
delay 5 -- wait while loading, loop one minute maximum,
-- after 1 minute, maybe the connection failed or the playlist doesn't exists
end repeat
end tell
on connectSource()
tell application "System Events" to tell scroll area 2 of window 1 of process "iTunes"
tell (first row of outline 1 whose value of it's static text 1 is "MY SHARED LIBRARY")
set b to exists
if b then select -- connect
end tell
end tell
return b
end connectSource


If you run the script from the " Scripts" menu in iTunes, you must
save it as Application, for not having the error message "Invalid index".

Apr 18, 2011 6:54 PM in response to Jacques Rioux

this new format has erased my response twice now and is kinda ******* me off. grrrr.


the gist of my previous two posts (they were much better explained/phrased).


THANK you very much. you very quickly answered a question that I had spent a fair amount of time looking for an answer to.


the code worked beautifully when i ran it by itself, but when i paired it with the rest of the code i wrote for this little project my follow up code never executed... i'm not sure if this is because of something in the handler/subroutine code or because the whole thing runs as an Automator application.


the edited code isn't as elegant, but it does the job I needed it to. Thank you very much for that.

tell application "iTunes"


activate

set sound volume to 100

tell front browser window to if minimized then set minimized to false

tell application "System Events" to tell scroll area 2 of window 1 of process "iTunes"

tell (first row of outline 1 whose value of it's static text 1 is "MY SHARED LIBRARY")

set b to exists

if b then select -- connect

delay 2

end tell

end tell

tell source "MY SHARED LIBRARY" to if exists then

tell user playlist "MY SHARED PLAYLIST" to if exists then

set shuffle to true

set song repeat to all

play some track

end if

end if

end tell


Apr 18, 2011 6:57 PM in response to Jacques Rioux

If you run the script from the "Scripts" menu in iTunes, you must
save it as Application, for not having the error message "Invalid index".


out of curiosity, what is that all about? what is it that makes the script need to be saved as an application to be run from an app specific script folder? I've seen that mentioned before, but it seemed a bit silly/defective.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

iTunes can't connect to shared library UNLESS it's manually connected?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.