AppleScript Programming/QuickTime full screen

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Copy the script, paste it into ScriptEditor, and save as an application.

When you drop a movie-file on the application, it'll first check if there is more than one file dropped into the application. If more than one, then it'll note about it and end the program. Else, it'll open QuickTime and bring it on front, open the dropped movie in QT, make it full screen and start playing it.

If you start the application with double-click, it'll just give you a dialog and quit.

(*
Works only as "Drag & Drop" program.

Written by F-3000
*)

on run
	display dialog "Drop a movie on the application icon." buttons {"OK"} ¬
		default button 1 with icon stop
end run

on open (dMovie)
	if (count (dMovie)) > 1 then
		display dialog ¬
			"Try dropping a single movie, if you don't mind." buttons ¬
			{"Quit"} default button 1 with icon stop
	else
		tell application "QuickTime Player"
			activate
			try -- Prevents error when QT is already open.
				close movie 1 -- Closes any possibly opening advertises.
			end try
			open dMovie
			present movie 1
			play
		end tell
	end if
end open