Autolaunch Fullscreen VLC Player in OSX
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.
BONUS 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
#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
UPDATE 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]
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /homepages/37/d93876897/htdocs/chris-reilly_dotorg_WP-2013/wordpress/wp-content/themes/chris-custom/content-blog.php on line 56
thanks a lot for this great tutorial. In fact, I used this exact method for quite a while in installations, and it worked pretty well.
But now I encountered two issues that drive me crazy:
1. when the computers (not accessible) start in the morning with connected beamers (HDMI) being on standby, the auto-fullscreen does not work. Even worse, the video is played somewhere in the background, not visible at all. This used to be different, but I have the impression that you cannot rely completely on what VLC does when no display is attached. If I restart with projector on, everything is fine, but this is no option. Sometimes it works, sometimes not, I think. Any ideas?
2. I used to have the mouse cursor problem, and now I am having it again in the described setting: in those cases in which the autostart works, the mouse cursor does not hide. Again, only with disconnected projector on startup. If everything is turned on and I do a restart,, the mouse hides. I could get rid of the mouse with some apple script moving it to the bottom with key strokes since it is out of the projection wall, but this is not very smart. Do you have any solution on this?
Sorry to bother you with these questions, but maybe you have encountered similar problems and know a quick fix.
Hi Mathis, I don’t think I’ve encountered these specific problems but here are some ideas.
1. You might be able to run a Detect Displays before deciding whether to launch VLC fullscreen. This is going down a path of making a more bloated program, which you seem to want to avoid. As I’ve gotten more into doing custom video installations, I’ve looked at other options like playing off a Raspberry Pi, which works pretty well as long as you don’t need it to loop absolutely seamlessly or have remote access. Lately I’ve been making video player apps in OpenFrameworks that autolaunch and do screen detection. This ends up being much simpler than the solution in the post above. If you are stuck using Mac’s for whatever reason, you can also install a remote manager like Teamviewer and do whatever reset/screen adjustment manually from any other internet-connected machine.
2. I would also try your solution of moving the mouse via script, but again this goes down the path of unnecessary bloat. Another advantage of using the Pi is that you can run it ‘headless,’ that is without the GUI.
At some point when I’ve got more free time I’ll write up a post about using the Pi as a video player. Until then good luck!
this helped me out a lot. Thank you for your work!
I have a similar but more complex issue, perhaps you can shed some light:
I need to project 3 distinct images (1080p ideally, 720 is ok) using 3 separate displays/projectors. They need to be in synch also, for art exhibit.
My equipment is two mac minis: i5 2.5 ghz 8gb ram 1TB SATA drive (2014 models, I believe),
so each has built in capability to output 2 displays.
question 1: Can I connect both macs in network and have one output 2 displays and the other 1 display? If so, how would I get them to synchronize? VLC? Resolume?
question 2: Would it be more feasable to get some hardware that allows 1 macmini to output 3 displays?
question 3: Can I program VLC to run the loop at a specific time and stop also at that time?
1) possibly, but I think it would require a bit of custom software to do exactly what you’d like. If you’re not comfortable doing this, see #2. Perhaps something readymade like this or this could work.
2) yes definitely this is the easiest option and very possible now with some of the newer media players available commercially; this is one, I haven’t used it but there are a few variations out there.
3) possibly you could do this with a cron job or a custom script, but at that point you’re back to the issues in question 1.