微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

告诉 QuickTime 使用 AppleScript

如何解决告诉 QuickTime 使用 AppleScript

我想使用 QuickTime 播放随机视频文件。我打开视频文件认应用程序是 VLC,所以我特意告诉 QuickTime Player 打开文件,而不是告诉 Finder 使用认应用程序打开文件

我在使用“某个文件”选择随机文件作为“告诉应用程序“QuickTime Player””部分的一部分时遇到了问题(我假设它只适用于应用程序“Finder”),所以我最终尝试一种解决方法是将随机文件复制到特定位置,然后打开该特定位置。

我目前的解决方案:

        tell application "Finder"
            set folderPath to "Macintosh HD:Users:username:Desktop:No Backup:Music:TimeOut:"
            delete (every item of folder folderPath whose name is "video.mp4")
            set sourceFile to some file of folder folderPath
            set duplicateFile to duplicate file sourceFile of folderPath
            set the name of duplicateFile to "video.mp4"
        end tell
        tell application "QuickTime Player"
            set theMovie to open "Macintosh HD:Users:username:Desktop:No Backup:Music:TimeOut:video.mp4"
            tell theMovie
                set the looping of theMovie to true
                set the present of theMovie to true
                play
            end tell
        end tell

这会导致以下错误,突出显示 duplicate file sourceFile of folderPath 位:

无法制作«class docf»“class cfol”的“随机video.mp4之一”“class cfol”的“TimeOut”“class cfol”的“音乐”“class cfol”的“无备份” «class cfol» 的“桌面” «class cfol» 的“用户名” 应用程序“Finder”的 «class sdsk» 的“用户”为整数类型。

脚本的 QuickTime Player 部分似乎工作正常;我正在尝试编写脚本的前半部分。

非常感谢您的帮助!

解决方法

下面的示例 AppleScript 代码folderPath对我有用variable 是一个正确的 HFS 路径:

set folderPath to ¬
    "Macintosh HD:Users:username:Desktop:No Backup:Music:TimeOut:"

tell application "Finder" to ¬
    set the fileToPlayInQuickTime to ¬
        some file of container folderPath as alias

tell application "QuickTime Player"
    set theMovie to open fileToPlayInQuickTime
    tell theMovie
        set the looping of theMovie to true
        set the present of theMovie to true
        play
    end tell
end tell

如果你想定位一个特定的typefile,假设目标文件夹中有各种类型 >,然后使用以下示例 AppleScript 代码,同时设置 name extension >property 与目标应用程序兼容:

tell application "Finder" to ¬
    set the fileToPlayInQuickTime to ¬
        (some file of container folderPath ¬
            whose name extension is "mp4") as alias

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。