It is time to upgrade your browser! This site looks and acts much better in a newer browser. Go TO THIS PAGE to find LINKS to all the major NEW BROWSERS. The links are at the bottom of the page under "What can I do?"

Or, you may keep reading this ugly page.

the MTAA-RR

[splash image]

MTAA-RR » news » twhid » geek » automate quicktime video on os x:

Dec 17, 2006

Automate QuickTime video on OS X

posted at 20:21 GMT by T.Whid in /news/twhid/geek

This post may be helpful for artists and other creatives that need to automate the launching of digital video files using QuickTime on the Mac OS.

MTAA is in a group show in January and we’re showing a simple digital video loop. The goal was to automate the launching of the video full screen and looping when the computer starts up. The strategy was to use an AppleScript as a login item to achieve this.

The straightforward way to do this is to create a script that tells QuickTime to open the file, play it full screen and loop by pointing to the explicit path of the file on disk, e.g bootdisk:path:to:foo.mov. The problem with this is that if the file is moved QuickTime can’t open it. To make it more error-proof I wanted to make one application package with the video inside it. This allows there to be one file that can be moved to any Mac and double-clicked to start the video playing with all the properties I need.

After a bit of research and trial-and-error I think I came up with a decent solution.

I should note here that you can set QuickTime movies to play full screen on launch in the Movie Properties/Presentation panel of QuickTime Pro, but I couldn’t find a way to tell it to always loop so I took the approach below. If there is a way to tell a QuickTime movie to loop on launch then I wasted a bunch of time ;-) On the other hand, for a video that QuickTime can play but isn’t wrapped in the QuickTime container (like a straight-up MPEG4) this is probably the only way to do it.

Regardless, this is what I did:

First, in Script Editor (/Applications/AppleScript/Script Editor), I created a new script and saved it as an ‘application bundle’ (making sure to uncheck ‘Startup Screen’). This created an application package — basically, a special folder — almost every OS X application is this format. By control-clicking this application in the Finder, I selected ‘Show Package Contents’ in the contextual menu. This opened a new Finder window with a folder called ‘Contents.’ Inside Contents was a folder called ‘Resources’ (and some other files). I copied my video file into the Resources folder.

Back to Script Editor, I typed a script very similar to this:

--set path to video file
set _f to ((path to me) as string) ¬
	& "Contents:Resources:foo.mov"

-- open and play it
tell application "QuickTime Player"
	launch
	activate
	stop every movie
	close every movie saving no
	try
		my play_movie(_f)
	on error
		(* in case the file has been 
		moved or deleted for some reason *)
		choose file with prompt ¬
			"File not found! Please locate it:"
		set _f to result
		my play_movie(_f)
	end try
end tell

on play_movie(_file)
	tell application "QuickTime Player"
		open _file
		tell movie 1
			(*
			you can put any properties you
			need in here
			*)
			set looping to true
			present scale screen
		end tell
	end tell
end play_movie
Note: this script doesn’t work when run from Script Editor. It needs to be saved and launched by double-clicking the application bundle.

In the end, I have a little app that contains my video, is easily copied from computer to computer and can be set as a login item so it launches automatically when the computer starts. For a bonus, it’s easy to replace the icon by replacing the file applet.icns in the Resources folder in the application bundle. I used CocoThumbX to create a new icns file.

Another tip: if you need to edit the script a bit, you should go into the bundle and open the main.scpt file in the [app bundle]:Contents:Resources:Scripts folder instead of editing the actual app bundle file. If your video file is large, it takes a long time to save the script when you’re editing the bundle as opposed to the script on it’s own. permanent link to this post

MTAA-RR » news » twhid » geek » automate quicktime video on os x


1997 - 2006 M.River & T.Whid Art Associates. Some Rights Reserved. MTEWW.com is licensed under a Creative Commons License with the exception of Website Unseen titles which are covered by agreements with individual collectors and otherwise where noted.