Play multiple movies in fullscreen Quicktime Pro 7

I am trying to take a folder that has a bunch of movies in it and play them one after another in full screen using Quicktime Pro 7.

Please excuse the rough outline, but this is pretty much what I want to do…

start Quicktime
start fullscreen
play the first movie in the folder
play the second movie in the folder
play the third movie in the folder

exit fullscreen
exit Quicktime

I am new to applescript, but it seems that this should be a pretty easy task. I can open each of the movies and play them in fullscreen, the problem I am having is that when I open and close each of the movies Quicktime exits and re-enters fullscreen mode. It is probably a combination of me thinking about this wrong and being new to applescript, but I could not find a way to keep quicktime in fullscreen at the application level rather than the movie level.

Right now this is pretty much what I am doing…

loop through files in the folder
open movie
present movie in fullscreen
play movie
close movie
end the loop

I was thinking the problem was opening and closing each movie, but this was the only thing that got me somewhat close to what I was trying to do.

Any help anyone could offer would be greatly appreciated. Thanks.

Hi Mike,

You could dynamically create a SMIL presentation with script. Here’s an example that has some extra stuff such as captions and a link that runs an AppleScript app just for my own information.

That works perfect Kel, very nice. I did a little reading and boiled it down to this.

Here’s a minimum smil file. You just need to set your video sources. These are the movies to be played sequentially. You may also want to change the root-layout width and height. My screen has a ratio of 4x3 so I just used 640x480 as the initial values. It doesn’t really matter since we’re going to play the video full screen anyway. Save this in TextEdit and give the file name an “.smil” extension.

Just to explain 2 things I put in the smil file…
qt:time-slider=“true” ← this allows you to see the time-slider in quicktime, without it there’s no way to scrub through the movie
qt:immediate-instantiation=“true” ← this makes quicktime look at all your video sources immediately and is done so the time-slider is more accurate

Thanks guys for the quick responses. I’m at work most of the day today, but I am excited to try this out tonight.

Hi regulus,

I didn’t try mpeg, but just QuickTime movie. Thanks for checking that out.

Here’s a quick rough script for putting the videos together:


property smil_begin : "<smil xmlns:qt=\"http://www.apple.com/quicktime/resources/smilextensions\"
qt:autoplay=\"true\" qt:time-slider=\"false\" qt:fullscreen=\"full\">
<head>
<meta name=\"title\" content=\"My Slideshow\"/>
<layout>
<root-layout background-color=\"black\" width=\"320\" height=\"290\"/>
<region id=\"videoregion\" top=\"0\" left=\"0\" width=\"320\" height=\"290\" fit=\"meet\"/>
</layout>
</head>
<body>
"
property smil_end : "</body>
</smil>"
property vidtag_begin : "<video src=\""
property vidtag_end : "\" region=\"videoregion\"/>"
--
set vid_text to ""
repeat
	try
		set f to choose file with prompt "Select a movie." & return & "Press cancel to start movie."
		tell application "Finder" to set vid_url to url of f
		set vid_text to vid_text & vidtag_begin & vid_url & vidtag_end & return
	on error
		exit repeat
	end try
end repeat
if vid_text is "" then return
set smil_text to smil_begin & vid_text & smil_end
set dp to (path to desktop as string)
set file_spec to (dp & "new.smil") as file specification
set ref_num to (open for access file_spec with write permission)
set eof ref_num to 0
write smil_text to ref_num
close access ref_num
tell application "Finder"
	set nchar to ASCII character 0
	set creator type of file_spec to nchar & nchar & nchar & nchar
	set file type of file_spec to nchar & nchar & nchar & nchar
end tell
tell application "QuickTime Player"
	launch
	activate
	open file_spec
end tell

The script asks the user to select movies until user presses cancel. A smil file is pllaced on the desktop and its file and creator types are changed so user can double click it to play later. Local file urls work, so the movies can be anywhere. the script needs work and error checking.

gl,

Hi Kel, I worked on your automating script. The code you used to write the file was giving me problems… so I inserted some code I use to write files… then the script worked. So here’s my script to automate the process of creating and launching the smil file. The subroutine I used to write the smil code has error checking built-in so the script should be good to go.

File types of mov, avi, and wmv seem to work but mpg files do not.

(*this script uses the Synchronized Multimedia Integration Language (SMIL) to create a way to view multiple movies in quicktime. When launched, the script presents a dialog box asking you to choose the movie files to view. Select as many as you want. After selecting the last movie file hit the "Cancel" button in the dialog box. A smil file called "new.smil" will be written to your desktop with the code to display the movies. If the file already exists, the previous contents will be overwritten with the new contents. The smil file will then be launched in quicktime and the movies you chose will be displayed in full screen sequentially in the order you chose them.*)

(*See http://developer.apple.com/documentation/quicktime/Conceptual/QTScripting_SMIL/index.html for more information on SMIL*)

--Note: Files types I tested that work are "mov" "wmv" "avi"... with the Perian and Flip4Mac QuickTime plugins
--Note: Files types that didn't work are "mpg"... I don't know why


property smil_begin : "<smil xmlns:qt=\"http://www.apple.com/quicktime/resources/smilextensions\" qt:time-slider=\"true\" qt:immediate-instantiation=\"true\">
<head>
<layout>
<root-layout background-color=\"black\" width=\"640\" height=\"480\"/>
<region id=\"videoregion\" width=\"100%\" height=\"100%\" fit=\"meet\"/>
</layout>
</head>
<body>
<seq>
"
property smil_end : "</seq>
</body>
</smil>"
property vidtag_begin : "<video src=\""
property vidtag_end : "\" region=\"videoregion\"/>"

set vid_text to ""
repeat
	try
		set f to choose file with prompt "Select a movie." & return & "Press cancel to start movie."
		tell application "Finder" to set vid_url to URL of f
		set vid_text to vid_text & vidtag_begin & vid_url & vidtag_end & return
	on error
		exit repeat
	end try
end repeat
if vid_text is "" then return
set smil_text to smil_begin & vid_text & smil_end
set dp to (path to desktop as string)
set fileName to (dp & "new.smil")

my writeTo(smil_text, fileName, false, string)

tell application "Finder"
	set nchar to ASCII character 0
	set creator type of file fileName to nchar & nchar & nchar & nchar
	set file type of file fileName to nchar & nchar & nchar & nchar
end tell

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

--=============Subroutines================
on writeTo(this_data, target_file, append_data, mode)
	try
		set target_file to target_file as Unicode text
		if target_file does not contain ":" then set target_file to POSIX file target_file as Unicode text
		set the open_target_file to open for access file target_file with write permission
		if append_data is false then set eof of the open_target_file to 0
		write this_data to the open_target_file starting at eof as mode
		close access the open_target_file
		return true
	on error
		try
			close access file target_file
		end try
		return false
	end try
end writeTo

Hi Mike and everyone,

It seems like this was fairly easy to do with Quicktime 6 as follows:

tell display 1 to enter full screen
tell movie 1 to play
tell movie 2 to play
tell movie 3 to play
tell display 1 to exit full screen

Is there a way to do that in Quicktime 7 without the use of SMIL, just using “pure” applescript?

Also, when I ran the SMIL solution, it seemed to bog down on the 2nd of two High Def movies (both w/ a resolution of 1920x1080). Is this because the video is streamed (a la Windows Media Player style) rather than buffered (the way Quicktime movies on the web usually are)? Is there a way to buffer things or at least make High Def movies play smoothly back to back using the SMIL method?

Just a follow-up to my mpg file problem…

From looking at the movie properties in Quicktime, the files I’m having problems using with this smil technique are MPEG 1 muxed files… the audio and video are in one track. I’m still not sure why they cause problems because they play fine in quicktime normally.

tenaciousjay, that’s what we’re trying to do and smil is the only solution we’ve found so far.

Hi,

As you said, regular movies have separate video and sound tracks. What the smil file does is create video tracks and sound tracks, so what it is doing is taking the muxed mpeg as the video track. I think you need to demux the mpeg first and create a movie with separate sound and video. The smil file won’t demux the muxed file.

gl,

to get back to the original question: playback all files in a folder one after the other
try this:

-- have QuickTime Play all files in choosen folder sequentually
tell application "Finder" to files of (choose folder)
set fileList to result

-- you may want to check the format of the files at this point

tell application "QuickTime Player"
	-- loop the files
	repeat with aFile in fileList
		open aFile
		tell front movie
			set {controller type, presentation mode} to {standard, normal}
			set current time to 0 -- = rewind 
			present scale screen display 1 background color {0, 0, 0}
			play -- just in case present didn't start playback already
			
			-- wait for end of playback allowing pause etc to happen
			repeat while ((playing is true) or (current time < duration))
			end repeat
			
			close
		end tell
	end repeat
end tell

Hey SwissAlps,

Thanks for the input. The real prob seems to be keeping the movies running in Full Screen between movies. Mike and I have talked about this quite a bit and we came up with a solution very similar to yours. We’ve been trying to get one movie to cut immediately to the next in fullscreen without minimizing and relaunching the next video (i.e. showing the desktop and whatever other windows you have open as it switches to the next movie). The SMIL methods listed above seemed to work and remain fullscreen between movies and cut immediately to the next movie without exposing any of the desktop or windows. Unfortunately, the SMIL methods also seem to bog down and play all the videos (except for the 1st) slowly and kinda jittery. So basically we just need to find a way to take your method and figure out how to remain in fullscreen the whole time (again, using Quicktime 7). Thanks again for posting!

Have you guys had any luck on this since the last post? I basically need to the do the same thing, play a series of movies, full screen and then have that sequence loop…

Any additional insight you could offer would be greatly appreciated. Thanks :slight_smile:

If the smil method doesn’t work for you then the only other way I can think to play the movies in full screen is by combining all of the video files into one file first, and then playing that newly created video file. Here’s a script to do that.

-- This script combines and converts the selected videos into one quicktime file. The new file is saved in the same location as the original videos. The name of the combined video file is the name of the first video with "_comb" added to it. Note: the movies are combined in alphabetical order.
-- To use: in the front Finder window select the videos you want to combine then run this script

set ml to {}
tell application "Finder"
	set a to selection
	repeat with i from 1 to count of a
		set end of ml to (item i of a) as string
	end repeat
	set the_container to container of file (item 1 of ml) as string
end tell
my Qsort(ml, 1, -1)

-- get the name and extension of the first file for use in the final file name
set nmExt to my getName_andExtension((item 1 of ml))

-- combine the selected videos
with timeout of 86400 seconds
	tell application "QuickTime Player"
		launch
		my supressAutoPlay(true)
		make new movie
		repeat with i from 1 to (count of ml)
			open file (item i of ml)
			if saveable of movie 1 is true then
				tell movie 1
					select all
					copy
					close saving no
					delay 0.2
					set dur to duration
					set current time to dur
					paste
					rewind
					select at 0 to 0
				end tell
			else
				display dialog "This movie has previously been set so that it cannot be copied, edited, or saved." & return & return & "Would you like to close this movie and continue processing the rest of the movies or stop the script?" buttons {"Close and Continue", "Stop"} default button 2
				set button_entered to button returned of result
				if button_entered is "Stop" then
					return
				else
					close movie 1 saving no
				end if
			end if
		end repeat
		tell movie 1
			rewind
			select at 0 to 0
			
			-- save the movie to the destination folder
			set new_file to (the_container & (item 1 of nmExt) & "_comb" & ".mov") as string
			save self contained in file new_file
			close saving no
		end tell
	end tell
end timeout

(*
-- move originals to trash
tell application "Finder"
	repeat with i from 1 to (count of ml)
		move item (item i of ml) to trash
	end repeat
end tell
*)

-- tell you that the script is finished
set the_dialog to "This script has finished converting the selected files!"
set frontApp to displayed name of (info for (path to frontmost application))
tell application frontApp to display dialog the_dialog buttons {"OK"} default button 1


(*================== SUBROUTINES ======================*)
on supressAutoPlay(status_flag)
	tell application "QuickTime Player"
		set ignore auto play to the status_flag
		set ignore auto present to the status_flag
	end tell
end supressAutoPlay

on getName_andExtension(F)
	set F to F as string
	set {name:Nm, name extension:Ex} to info for file F
	if Ex is missing value then set Ex to ""
	if Ex is not "" then
		set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
		set Ex to "." & Ex
	end if
	return {Nm, Ex}
end getName_andExtension

on Qsort(theList, L, r)
	-- Qsort sorts a list
	-- the authors of Qsort are Arthur Knapp and Nigel Garvey
	-- the script can be found in item 2 of http://bbs.applescript.net/viewtopic.php?id=17340
	script o
		property cutoff : 10
		property p : theList
		
		on qsrt(L, r)
			set i to L
			set j to r
			set v to my p's item ((L + r) div 2)
			
			repeat while (j > i)
				set u to my p's item i
				repeat while (u < v)
					set i to i + 1
					set u to my p's item i
				end repeat
				
				set w to my p's item j
				repeat while (w > v)
					set j to j - 1
					set w to my p's item j
				end repeat
				
				if (i > j) then
				else
					set my p's item i to w
					set my p's item j to u
					set i to i + 1
					set j to j - 1
				end if
			end repeat
			
			if (j - L < cutoff) then
			else
				qsrt(L, j)
			end if
			
			if (r - i < cutoff) then
			else
				qsrt(i, r)
			end if
		end qsrt
		
		on isrt(L, r)
			set x to L
			set z to L + cutoff - 1
			if (z > r) then set z to r
			
			set v to my p's item x
			repeat with y from (x + 1) to z
				if (my p's item y < v) then
					set x to y
					set v to my p's item y
				end if
			end repeat
			
			tell my p's item L
				set my p's item L to v
				set my p's item x to it
			end tell
			
			set u to my p's item (L + 1)
			repeat with i from (L + 2) to r
				set v to my p's item i
				if (v < u) then
					set my p's item i to u
					repeat with j from (i - 2) to L by -1
						if (v < my p's item j) then
							set my p's item (j + 1) to my p's item j
						else
							set my p's item (j + 1) to v
							exit repeat
						end if
					end repeat
				else
					set u to v
				end if
			end repeat
		end isrt
	end script
	
	set listLen to (count theList)
	if (listLen > 1) then -- otherwise the handler will error
		-- Translate negative indices
		if (L < 0) then set L to listLen + L + 1
		if (r < 0) then set r to listLen + r + 1
		
		if (r = L) then
			-- No point in sorting just one item
		else
			-- Transpose transposed indices
			if (L > r) then
				set temp to L
				set L to r
				set r to temp
			end if
			
			if (r - L < o's cutoff) then
				-- Skip the Quicksort if cutoff or less items
			else
				o's qsrt(L, r)
			end if
			o's isrt(L, r)
		end if
	end if
	
	return -- the original name of your list is the returned value
end Qsort

One other thought… you can create a “reference movie” instead of creating a totally new “self contained” movie. The reference movie references the selected video files. To get a reference movie change the following line in my above script.

from: save self contained in file new_file
to: save in file new_file as reference

Good luck!