Full screen QuickTime Player for computers with multiple displays

(*This script was written because I have 2 displays attached to my computer and I haven't found a way to play a movie full screen on my second display with QuickTime using applescript. Quicktime does have an applescript setting for this, but that setting doesn't work for me (or anybody else I've seen through my searches)*)

-- you choose a movie and then choose which monitor you want to play it full screen on
-- Note: QuickTime Player has to quit for this to work, so anything open in quicktime will be closed


set fileName to choose file with prompt "Pick a movie to play full screen" without invisibles

set displaysInfo to my displays_info()
set numMonitors to displayNumber of (item -1 of displaysInfo)

set changeDefaults to true
if numMonitors = 1 then
	set changeDefaults to false
else if numMonitors = 2 then
	set theButtons to {"Cancel", "1", "2"}
else if numMonitors > 2 then
	set theButtons to {"1", "2", "3"}
end if

if changeDefaults is true then
	-- get the displayID of the chosen display
	set tempVar to display dialog "On which of your displays would you like to present the movie?" buttons theButtons
	set displayNum to button returned of tempVar
	set displayID to displayID of (item displayNum of displaysInfo)
	
	--write the setting to the quicktime player plist
	set prefFile to "com.apple.quicktimeplayer"
	set keyP to "FullscreenPreferenceScreenNumber"
	set valueP to displayID
	set typeP to "integer"
	tell application "QuickTime Player" to quit
	my writeDefault(prefFile, keyP, valueP, typeP)
end if

tell application "QuickTime Player"
	activate
	open fileName
	present movie 1 scale screen
end tell


--================Subroutines======================
on writeDefault(prefFile, keyP, valueP, typeP)
	do shell script "defaults write " & "'" & prefFile & "' '" & keyP & "' '-" & typeP & "' '" & valueP & "'"
end writeDefault

on displays_info()
	set plistFolderPath to (path to preferences folder as string) & "ByHost:"
	tell application "Finder" to set plistName to (name of files of folder plistFolderPath whose name contains "com.apple.windowserver") as string
	set plistPath to plistFolderPath & plistName
	set j to 1
	tell application "Image Events" to set count_of_displays to count of displays
	repeat
		set displaysInfo to {}
		tell application "System Events" to set displaySet to value of property list item j of property list item "DisplaySets" of property list file plistPath
		try
			repeat with i from 1 to count_of_displays
				set expID to |DisplayID| of (item i of displaySet)
				set exp_to_string to words of (expID as string)
				set stringID to (character 1 of (item 1 of exp_to_string)) & (characters 3 thru -2 of (item 1 of exp_to_string)) as string
				if (count of stringID) < ((item 3 of exp_to_string) + 1) then
					repeat with i from (count of stringID) to (item 3 of exp_to_string)
						set stringID to stringID & "0"
					end repeat
				end if
				set end of displaysInfo to {displayNumber:i, displayID:stringID}
			end repeat
			exit repeat
		on error
			set j to j + 1
		end try
	end repeat
	return displaysInfo
end displays_info

Hi,

I discoverd this forum while searching for Applescript help and I see that it may become invaluable to me in my new line of work…

I am trying to display two movies, full screen on a second and third monitor automatically without any user intervention. Basically, I have a Mac Pro with a main display and two 30" cinemas attached as 2nd and 3rd monitors. I have two quicktime movies, one for each monitor, that need loop and then play simultaneously (they are timed specifically so that one movie rolls into the next). I have come up with the following code to do this for me automatically. My problem is that one of the movies is presented on the primary display and not on the third display. Is there any way to use the code you have developed above in my application?


tell application "Finder"
	open {document file "left_dark.mov" of folder "Menu Boards" of startup disk}
end tell

activate application "QuickTime Player"
tell application "System Events"
	tell process "QuickTime Player"
		click menu item "Loop" of menu 1 of menu bar item "View" of menu bar 1
	end tell
end tell

tell application "Finder"
	open {document file "right_dark.mov" of folder "Menu Boards" of startup disk}
end tell

tell application "System Events"
	tell process "QuickTime Player"
		click menu item "Loop" of menu 1 of menu bar item "View" of menu bar 1
		click menu item "Play All Movies" of menu 1 of menu bar item "View" of menu bar 1
	end tell
end tell

tell application "QuickTime Player"
	present movie 1 display 2
	present movie 2 display 3
end tell

I’ve been out of town and just got back last night… here’s some thoughts for your problem.

You can’t do this with quicktime alone because I found that the applescript “display” command doesn’t work properly with quicktime. To get around this problem, if you notice in my script above, to make a movie display on a chosen screen I write the “display id” of the chosen display to the preference file of quicktime, then the movie will present properly. Now in your situation this doesn’t help you with 2 movies because in order for quicktime to read the preference file it has to be quit and relaunched each time the preference is changed, and thus it can’t work on more than 1 movie.

So here’s my suggestion for your situation. Use Quicktime to present one movie and another program to present the other movie. I tried this with VLC as the second program and it works well. Here’s the code I used for VLC. I incorporated the “looping” stuff you wanted in it. So all you have to do is put my quicktime code from above together with this VLC code into one script and you should get it to work the way you want.

set theDisplay to 2 -->the display to play the movies
set theMovie to choose file without invisibles

tell application "VLC"
	activate
	open theMovie
	delay 0.2
end tell
tell application "System Events" to tell process "VLC"
	click menu item (theDisplay + 1) of menu 1 of menu item "Video Device" of menu 1 of menu bar item "Video" of menu bar 1
	click menu item "Repeat All" of menu 1 of menu bar item "Playback" of menu bar 1
end tell
tell application "VLC" to fullscreen

@magisimo: maybe the display count starts at 0, so 3 would be 4, which points back to main screen.
a)what happens if you present both movies on display 2?
b)what happens if you add a third movie to the game? You could close the movie on your main display once all three are rolling.

I’m not in the position to test a third display, but on my dual setup, QuickTime presents an additional movie on the other display automatically. Even when I enter “4” as display No. for both movies.

property leftMovPath : "/path/to/leftDark.mov"
property rightMovPath : "/path/to/rightDark.mov"

tell application "QuickTime Player"
	activate
	open leftMovPath
	set leftMov to movie 1
	open rightMovPath
	set rightMov to movie 1

	set leftMov's looping to true
	set rightMov's looping to true
end tell

tell application "System Events"
	tell process "QuickTime Player"
		click menu item "Play All Movies" of menu 1 of menu bar item "View" of menu bar 1
	end tell
end tell

tell application "QuickTime Player"
	present rightMov display 3
	present leftMov display 3
end tell


I depreciate the use of plist files when it comes to monitor info. I have found them to be inaccurate. http://bbs.applescript.net/viewtopic.php?pid=76713#p76713
“call method” commands return accurate results :smiley: