QuickTime Pro save self contained MKV

Hey,

I am trying to create an AppleScript capable of making QuickTime Pro open a movie, save it as mov and import it as a tv show into iTunes.

My script can already do this, except when I try to import H264 MKV files. The reason is that when I ask QuickTime to load:


		tell application "QuickTime Player"
			open thisItem
			
			set movieLoc to exportFolder & ":Converted:" & exportPrefix & ".mov"
			
			if (can export front document as QuickTime movie) then
						save self contained front document in movieLoc
			else
				display dialog "QuickTime is not able to convert this file: " & (get name of (info for thisItem without size)) buttons "Ok" default button 1 with icon caution
			end if
			
			close front document
		end tell

it will open the file and immediately try to convert the file which will fail since it takes QuickTime a minute or two to actually be able to play the file. So my real question is: Is there a way to know when QuickTime has finished loading the MKV file ? and then initiate the conversion ?

Model: MacBook Pro Unibody
AppleScript: 2.0.1
Browser: Safari 528.17
Operating System: Mac OS X (10.5)

I solved it my self but thought I would share the solution:


			if (can export front document as QuickTime movie) then
				repeat
					if ((get load state of front document) = complete) then
						repeat
							try
								save self contained front document in movieLoc
								exit repeat
							end try
						end repeat
						exit repeat
					end if
				end repeat
			else
				display dialog "QuickTime is not able to convert this file: " & (get name of (info for thisItem without size)) buttons "Ok" default button 1 with icon caution
			end if

The secret lied in the load state (DU’H)