macnoob768

macrumors newbie
Original poster
Jan 13, 2012
1
0
I am having a problem with trying to figure out why I have this error showing up. I am trying to play a movie in full screen and in a loop with QuickTime Player Version 10.1 (501) on my Mac Mini. What I want to do is to be able to play the movie, full screen, and in a loop when I restart my Mac. I put the script in my login items, but when I restart my Mac or reboot it, the error shows "Can't get document 1. Invalid index." and the movie does show up, but does not play, not in full screen, and not in a loop. Only when I click the script again will it do all those things I want. If anyone can help me out, I really appreciate it and also, I did save it as an application. Thank you.

Here is the code of what I have:

tell application "QuickTime Player"
activate
open "PathtoFile:movie.mov"
set looping of document 1 to true
present document 1
play document 1
end tell
 

Mark FX

macrumors regular
Nov 18, 2011
149
15
West Sussex, UK
Red Menace is absolutly right, several problem Applescript posts recently, have not taken into account, that Applescript is a slow language, and applications need time time to react to its requests, so always use the delay command, this allows the scriotable application time to react to the commands.

I have rewritten your script, so try this version, it seems to work OK, but I hav'nt tried it on a restart, so if you have problems with it on a restart, I'll rewrite again for you.

Code:
tell application "QuickTime Player"
	activate
	try
		set movieFile to ((path to movies folder) & "Dancer.mov" as text) as alias
	on error errorMsg number errorNum
		display alert errorMsg & space & errorNum message ¬
			"An error occured trying to find the file " & movieFile & "." & return & ¬
			"Check the file path exists, and the file spelling." as warning giving up after 60
	end try
	try
		open movieFile with presenting
		delay (0.25)
		present document 1
		delay (0.25)
		set looping of document 1 to true
		play document 1 with looping
	on error errorMsg number errorNum
		display alert errorMsg & space & errorNum message ¬
			"An error occured trying to open & play the file " & movieFile & "." & return & ¬
			"Check the file path exists, and the set delay time" as warning giving up after 60
	end try
end tell

Also I have used the path to a movie file on my system, but you will have to change the line.

Code:
set movieFile to ((path to movies folder) & "Dancer.mov" as text) as alias

To point to the file you want on your system.

Hope this helps.

Regards Mark
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.