2012-05-23 67 views
0

我想玩一個電影全屏一次,然後關閉播放器可編程。 我嘗試過使用QTMovieView,命令行和AppleScript,發現Applescript是最簡單的方法。關閉通過Applescript QuickTime

但是,因爲我真的不知道Applescript,我不能讓電影播放後的QuickTime自動關閉。

一切工作正常,但「完成」無法識別的重複行。 以下是帶有此錯誤的腳本:

錯誤「QuickTime Player出現錯誤:無法將文檔1插入到類型說明符中。」編號-1700從文件1完成到說明者

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 

最後,我改成了這個,這樣好嗎?

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 

新問題:應用在視頻完成前掛起。

+0

你不需要重新啓動你之前的退出程序。在退出之前,您也不需要關閉文檔1。試試我的編輯版本。 – adayzdone

+0

我可以將延遲1從中間移動到結束重複嗎? –

回答

2

這對我有用,但它看起來不太健壯。 保證current time將永遠等於duration,因爲它們都是實數嗎?您可能需要在「」條件下放入「epsilon」邏輯。

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 
+0

謝謝格雷厄姆,它的工作原理!但QuickTime Player在播放後沒有退出。我應該使用close嗎? –

+0

只需將「關閉文檔1」更改爲「退出」即可。我沒有意識到你想退出應用程序的問題。 – 2012-05-24 07:00:28

0

嘗試:

tell application "QuickTime Player" 
    tell document 1 
     present 
     play 
     repeat until playing is false 
      delay 1 
     end repeat 
    end tell 
quit 
end tell 
+0

謝謝adayzdone,它也可以!但QuickTime Player在播放後沒有退出。我應該使用close嗎? –

+0

嘗試編輯的版本。 – adayzdone

+1

如果有人暫停視頻,你想讓應用程序退出嗎? – 2012-05-24 07:01:06