I am trying to play a movie fullscreen one time, then close the player programmably. I have tried using QTMovieView, command line and AppleScript and found the Applescript is the most simple way.
BUT, as I really don't know Applescript, I can not make the QuickTime auto close after movie playing.
Everything works fine but the "done" was unrecognized in the repeat line. Here is the script with this error:
error "QuickTime Player got an error: Can't make done of document 1 into type specifier." number -1700 from done of document 1 to specifier
tell application "QuickTime Player"
activate
open "/Users/...real path of the movie.mov"
present document 1
play document 1
repeat until (get done of document 1)
end repeat
delay 2
close document 1
end tell
Finally, I changed to this, is this ok?
tell application "QuickTime Player"
quit
end tell
tell application "QuickTime Player"
activate
open "/Users/.../...mov"
tell document 1
present
play
repeat until playing is false
end repeat
delay 2
close
end tell
quit
end tell
New problem: app hang before video finish.
This works for me, however it doesn't seem very robust. Is it guaranteed that the current time
will always end up being equal to the duration
, given that they're both reals? You may want to put some "within epsilon" logic into the repeat
condition.
tell application "QuickTime Player"
play document 1
repeat until (current time of document 1 = duration of document 1)
end repeat
delay 2
close document 1
end tell