I had a need to set up a computer (running OSX 10.8.3 Mountain Lion) as an automated fullscreen video player for an art exhibition. I made a simple AppleScript application to automatically launch VLC fullscreen and run a looping video. Here’s the code:
#this runs at startup via the Login Items on the default acct, which should be set to auto-login. Use Energy Saver's scheduling option to set a start/wake time do shell script "/Applications/VLC.app/Contents/MacOS/VLC /path/to/your/video-file.mov --fullscreen" tell me to quit
Open a new doc in AppleScript Editor, and paste in the code above. Note:
- your copy of the VLC app may be in a place other than /Applications/VLC.app/Contents/MacOS/VLC
- change /path/to/your/video-file.mov to the actual file path of the video you’d like to autolaunch.
To export as an application, choose File->Export and set the File Format to Application. Save to wherever you like.
To autolaunch on startup, go to System Preferences -> Users & Groups -> Login Items and add your app.
You may also want to have the machine automatically shut down (at night for instance), then reboot in the morning. You can usually set this up by using a simple cron command that will shut down the machine at a given time, and/or OSX’s built-in Energy Saver Schedule (under System Prefs -> Energy Saver -> Schedule… ).
Trouble is, VLC seems to override the automatic shutdown methods, so in order to shut down properly, we need to tell VLC to stop playing and quit before shutting down/rebooting. Here’s how to do that:
tell application "VLC" to stop tell application "VLC" to quit #quit all running apps, VLC included tell application "System Events" to set quitapps to name of every application process whose visible is true and name is not "Finder" repeat with closeall in quitapps quit application closeall end repeat #now it should be easy to shut down the machine #we can do it here, or via the system's crontab #do shell script "/sbin/shutdown -h now"
Save out as an Applescript, and you’re good. In my setup I used the system’s cron schedule to run the above VLC shutoff script, then one minute later shutdown the machine. To do this, in Terminal issue the command:
sudo crontab -e
Then set the timing of your script & shutoff command like so:
#make VLC stop playing & the shutdown all apps 01 21 * * * osascript /path/to/shutdown-script.scpt #shutdown the whole machine. it will restart via Energy Saver 02 21 * * * /sbin/shutdown -h now
I noticed that sometimes VLC, when running fullscreen video, would show a ghosted outline of the OSX menu bar and its icons over the video, which looked terrible. I found that updating to the latest VLC fixed this problem.
Also, since I was running without a keyboard & mouse, I shut off the annoying OSX Bluetooth auto-search on boot in System Preferences -> Bluetooth -> Advanced -> Open Bluetooth Setup Assistant… [disable this]