Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Apple TV can't load iTunes library that has gone to sleep

I'm having a very frustrating problem with my Apple TV.


Here is the setup: I have an Apple TV in my bedroom that I use to connect to my iTunes library that is set up with Home Sharing on an iMac in my living room. The actual iTunes library is stored on an external drive connected to the iMac. Everything is connected directly via ethernet so there is no WiFi in this setup. The Mac/iTunes/Apple TV have all the latest updates and patches installed.


The problem: When everything is working, everything is fine. The problem arises if I try to connect to my library on the Apple TV after the mac has gone to sleep. The Apple TV will see my library but every attempt to connect to it hangs on the 'Loading xxx libray' message and times out. It's not a network problem because I can still access things like trailers or YouTube. If I go out to the living room and wake the mac and/or restart iTunes everything works fine again.


Fixes?: I'm assuming it's a problem with the Apple TV not being able to wake up the remote mac and/or possibly a problem that the hard drive containing the iTunes library has gone to sleep and spun down. I've tried chaning the Mac system settings to prevent the cpmputer from going to sleep and turned on wake for network acces but that does not seem to work. I haven't played with Put the hard disk(s) to sleep when possible yet but I don't like the idea of having all my disks running 24/7 if they're not being accessed.


Has anyone else had this same problem? What setting worked for you?

Posted on May 7, 2012 12:15 PM

Reply
97 replies

Aug 13, 2012 5:26 PM in response to TitanBry77

In console, make sure you click the Show Log List icon to show all the log files. Then make sure you have "All Messages" selected under System Log Queries. That should show you all the system logs. Then look for entries prefixed with "iTunesFix:".


Another way to see if it worked is to stop the script by executing the following commands


cd ~/Library/LaunchAgents

launchctl unload com.corknation.fixhomesharing.plist


Then quit iTunes. Then launch the agent again and since iTunes was closed, it should launch iTunes (but it will launch minimized so just make sure that you can tell by the icon on the Dock that it's running).


cd ~/Library/LaunchAgents

launchctl load com.corknation.fixhomesharing.plist



If you watch the console, every hour you should see a new entry prefixed with "iTunesFix:". That's how you know its running every hour.

Aug 13, 2012 5:43 PM in response to TitanBry77

Maybe the "open" command in 10.5.8 doesn't support -j. Try this. From the terminal, type open and hit return. You should get a listing of the options open supports. Mine from 10.8 looks like this


office-imac:~ rob$ open

Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]

Help: Open opens files from a shell.

By default, opens each file using the default application for that file.

If the file is in the form of a URL, the file will be opened as a URL.

Options:

-a Opens with the specified application.

-b Opens with the specified application bundle identifier.

-e Opens with TextEdit.

-t Opens with default text editor.

-f Reads input from standard input and opens with TextEdit.

-F --fresh Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.

-R, --reveal Selects in the Finder instead of opening.

-W, --wait-apps Blocks until the used applications are closed (even if they were already running).

--args All remaining arguments are passed in argv to the application's main() function instead of opened.

-n, --new Open a new instance of the application even if one is already running.

-j, --hide Launches the app hidden.

-g, --background Does not bring the application to the foreground.

-h, --header Searches header file locations for headers matching the given filenames, and opens them.



If your output doesn't have -j, then you will need to modify the fixhomesharing.sh file to change "open -j -a iTunes" to "open -a iTunes". There are 5 places you'll need to change it. Then just save the file. Now unload and load the plist and it should work (hopefully).


I wrote this on 10.8 so i can't test it on 10.5. Let me know how it goes.

Aug 13, 2012 5:50 PM in response to TitanBry77

Bingo, works! Thank you so much! I've learned a lot about this Mac stuff too lol. So, if I have to reboot the MAC, which hardly ever happens, will it automatically load that script or do I have to do the launchctl again from terminal.


I dont know if whatever I put in the "LaunchAgents" folder that I made since one didn't exist will automagically reload on reboot.

Aug 13, 2012 5:53 PM in response to TitanBry77

The script will launch whenever you log into that account (which is necessary to have iTunes running). You don't need to do anything more at this point. I would say to watch the Console logs for the next few days just to make sure you see entries each hour and whether it restarted iTunes or not.


I'm probably going to modify the script over the next few days to add in logic to check whether iTunes is playing media locally and not restart if it is. That way if i'm listening to music on the computer it doesn't restart it in the middle.

Aug 16, 2012 1:08 AM in response to Tom Roehl

Okay, so I loaded the script and things seemed to be working fine for the last two days. Just got home now and tried to watch a movie and I got the dreaded 'Loading Library' again.


Checked the console and it ran the script only 20 minutes ago.


16/08/12 5:43:48.468 PM iTunesFix[2332]: iTunes is already running. Check if it's preventing sleep

16/08/12 5:43:48.513 PM iTunesFix[2343]: iTunes is currently preventing sleep (streaming?). Do nothing


Not sure what happened??

Sep 14, 2012 5:54 AM in response to rcork

I have been using your script and Lingon since Mid August. Everything was working fine until recently. Now, every hour even when streaming from iTunes. iTunes quits and relaunches, which of course causes your movie on Apple TV to stop. I really thought your fix had put an end to the AppleTV/iTunes troubles. Any ideas?


Thank you...

Oct 29, 2012 4:46 PM in response to TitanBry77

You can use Lingon to delete the job or a few commands in Terminal. I think it's pretty self explanatory if you use Lingon. If you want to use the command line, launch Terminal and type the following commands, hitting return after each one:


cd ~/Library/LaunchAgents/

launchctl unload com.corknation.fixhomesharing.plist

rm com.corknation.fixhomesharing.plist

Apple TV can't load iTunes library that has gone to sleep

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