限制铃声长度 AppleScript

发布于 2024-10-19 14:37:08 字数 293 浏览 6 评论 0原文

我有下面显示的 AppleScript 代码,它告诉 iTunes 转换所选曲目。我想知道如何限制要转换的曲目的长度?

tell application "iTunes"
    set theFiles to the selection

    repeat with theTrack in theFiles
        with timeout of 120 seconds
            set theSecondTrack to first item of (convert theTrack)

I have the AppleScript code shown below which tells iTunes to convert the track from the selection. I was wondering how I would limit the length of the track that will be converted?

tell application "iTunes"
    set theFiles to the selection

    repeat with theTrack in theFiles
        with timeout of 120 seconds
            set theSecondTrack to first item of (convert theTrack)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泛滥成性 2024-10-26 14:37:08

如果您想通过 iTunes GUI 限制转换后的曲目的长度,您可以在“获取信息”>“选项”中设置原始曲目的“停止时间”。相应的 AppleScript 属性是 finish (属于 track 类)。

因此,重复循环中的步骤应该是:

  1. 获取曲目的原始停止时间(通常这只是曲目的完整持续时间)
  2. 将停止时间设置为限制长度(以秒为单位)
  3. 转换曲目
  4. 设置停止时间回到 1 时的状态。

示例 60 秒限制:

repeat with theTrack in theFiles
    tell theTrack
        set originalFin to finish
        set finish to 60

        -- Track conversion code goes here

        set finish to originalFin
    end tell
end repeat

If you wanted to to limit the length of the converted track via the iTunes GUI, you would set the "Stop Time" of the original track in Get Info>Options. The corresponding AppleScript property for this is finish (of the track class).

So the steps in your repeat loop should be:

  1. Get the original stop time of the track (usually this will just be the full duration of the track)
  2. Set the stop time to your limit length (in seconds)
  3. Convert the track
  4. Set the stop time back to what it was at 1.

Example 60-sec limit:

repeat with theTrack in theFiles
    tell theTrack
        set originalFin to finish
        set finish to 60

        -- Track conversion code goes here

        set finish to originalFin
    end tell
end repeat
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文