首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用Applescript关闭QuickTime

用Applescript关闭QuickTime
EN

Stack Overflow用户
提问于 2012-05-24 06:40:18
回答 2查看 2.7K关注 0票数 0

我正试着全屏播放一部电影,然后可编程地关闭播放器。我尝试过使用QTMovieView、命令行和AppleScript,发现Applescript是最简单的方法。

但是,因为我真的不知道Applescript,所以我不能让QuickTime在电影播放后自动关闭。

一切正常,但重复行中的"done“未被识别。以下是包含此错误的脚本:

错误"QuickTime Player出现错误:无法将文档%1转换为类型说明符。“编号-1700,从文档1的done到说明符

代码语言:javascript
复制
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

最后,我改成这样,这样可以吗?

代码语言:javascript
复制
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 

新问题:应用程序在视频结束前挂起。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-24 06:51:47

这对我来说很有效,但是它看起来不是很健壮。既然current timeduration都是真实的,那么是否可以保证它们最终总是相等的呢?您可能希望在repeat条件中加入一些“在epsilon内”的逻辑。

代码语言:javascript
复制
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
票数 2
EN

Stack Overflow用户

发布于 2012-05-24 09:33:05

尝试:

代码语言:javascript
复制
tell application "QuickTime Player"
    tell document 1
        present
        play
        repeat until playing is false
            delay 1
        end repeat
    end tell
quit
end tell
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10728854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档