How to Automate the Playing of a Movie

This recipe walks through scheduling a movie to starting playing on loop.

Being able to play back a movie automatically is useful in many situations such as museum installations, trade shows, and in office lobbies. Getting a Mac to play a movie without human interaction can be tricky. Thankfully Power Manager's new Play a movie task makes it easy.

Power Manager includes a task that deals with launching your movie in QuickTime Player and starting playback automatically. Through the task, you can play the movie back in full screen mode and ask the movie to loop forever. Both these features are optional but for most situations they will be ideal.

Why can playing a movie be tricky? QuickTime Player supports AppleScript. This means it should be possible to use the following AppleScript snippet:

tell application "QuickTime Player"
    open myMoviePath
    play the frontmost document
end tell

This does sometimes work but sometimes it does not. This lack of consistency is what makes this AppleScript look simple and easy but unusable.

If the movie has not finished loading by the time play is requested, nothing will happen. Sometimes loading is immediate and other times loading can take a moment or two - or even minutes.

To fix this, our AppleScript must open the movie and wait until it is loaded. Only once the movie is loaded can QuickTime Player start playing it.

Power Manager's Play a movie task deals with this for you. The task hides the complexity from you and reduces your main choices to what movie and when to play. Behind the scenes the task creates an event with an embedded AppleScript that talks to QuickTime Player. The script does the following:

  • Launches QuickTime Player
  • Opens your movie
  • Tries to play the movie
  • If the movie can not play, wait and try again in a moment
  • If too long passes, give up and avoid looping forever

Let's use the Schedule Assistant to create an event.

Create Play a Movie Event

The event will automatically start playing a movie in QuickTime Player once a day at 8:30am.

  1. Launch Power Manager.app
  2. Click Add… to create a new event
    Click add to create an event

    Click add to create an event

  3. Select the Play a movie task in the Schedule Assistant
    Select the Play a movie task

    Select the Play a movie task

  4. Choose or drag and drop your movie onto Play which movie?
    Choose the movie to automatically play

    Choose the movie to automatically play

  5. Set up the Play full screen? and Should the movie loop? as needed
  6. Continue to the When step
  7. Adjust the time and days of the week
    Adjust the days and time to start playing

    Adjust the days and time to start playing

  8. Continue to the Constraints step; we will skip the constraints for this recipe
    Continue passed the Constraints step

    Continue passed the Constraints step

  9. Continue to the Why step
  10. Name your new event and provide any notes
    Name your new event

    Name your new event

  11. Add to create your new movie playing event
    Confirm the creation of the new event

    Confirm the creation of the new event

    Your new movie playing event is ready

    Your new movie playing event is ready

With the event created, you may like to create an event to power on your Mac a little earlier in the day. You can combine as many events as needed to get the behaviour you want.

For an art installation, you might want to power on the Mac each morning, wait a few minutes, then start a movie looping in full screen mode. At the end of the day, another event shuts down the Mac for the night. These events manage the Mac without needing any human involvement or management. It just works.

This article was posted in , , , and and tagged , and .

Published by Graham Miln on