What if Quicktime annotation doesn't exist?

Hello.

I’m working with a script to display movies on an HD screen and display their names and other info in a Word Document on another screen. This script works, for the most part:

property a_List : {}


repeat
	
	tell application "QuickTime Player"
		
		tell document 1 to if exists then
			
			set my_list to {full text of annotation "artist", full text of annotation "information", full text of annotation "description"}
		end if
		
		if my_list is not a_List then my paste_into_Word(my_list)
		delay 5
		
	end tell
end repeat

on paste_into_Word(L)
	set a_List to L
	set {annot_artist, annot_title, annot_class} to L
	tell application "Microsoft Word"
		set content of text object of active document to annot_title & return & return & annot_artist & return & return & annot_class
	end tell
	
end paste_into_Word

  • but if the Quicktime movie is not annotated, then the script stops and I get an error message, “Quicktime Player got an error: Can’t get annotation “artist” of document 1.” This makes sense, since there is no annotation, I’m just wondering what sort of if statement I could put in to check for this. The pseudo code would be:

If there is no artist annotation, paste a bunch of spaces in the file
If there is no information annotation, paste a bunch of spaces in the file
If there is no description annotation, paste a bunch of spaces in the file
Keep checking

Any help would be greatly appreciated!

Thanks,

  • Bruce

Hi,

try this


property a_List : {}

repeat
	tell application "QuickTime Player"
		if document 1 exists then
			tell document 1
				repeat with i in {"artist", "information", "description"}
					if exists annotation i then
						set end of my_list to full text of annotation i
					else
						set end of my_list to "            "
					end if
				end repeat
			end tell
		end if
	end tell
	if my_list is not a_List then paste_into_Word(my_list)
	delay 5
end repeat

on paste_into_Word(L)
	set a_List to L
	set {annot_artist, annot_title, annot_class} to L
	tell application "Microsoft Word"
		set content of text object of active document to annot_title & return & return & annot_artist & return & return & annot_class
	end tell
end paste_into_Word

Stefan -

Thanks for the reply.

When I first ran this, it immediately came up with an error - “my_list is not defined”, so I set an initial value for my_list as the first line of the script:

set my_list to {Welcome, **************, ***************}

But then when I ran it, it displayed this text in the word file, but ignored anything happening in Quicktime.

Any ideas?

There are several things in the script you sent that are beyond my limited scripting understanding, so I haven’t tried much. Any pseudocode would be really helpful in learning some of this, too.

Thanks again,

  • Bruce

Right, the variable is not defined


.
repeat
	set my_list to {}
.

I don’t have any movies with annotations, but the rest should work.
In the repeat loop there’s an existence check for each annotation.
In case of existence the full text will be appended to the list, otherwise some spaces