Applescript:如何让 Podcasts 具备快进功能?
Podcasts Fastward AppleScript
作者: Frank 发布时间: 2012-08-31 #Applescript #Podcast #podcasts #QuickTime

最近突然爱上用Mac听Podcasts,有时一听就是整半天,不过节目中难免有一些段落或听过的部分需要跳过,但iTunes又没有快进功能,还好又让小编遇到了一个解救技巧,那就是Applescript,这货真的是无所不能,能够控制Podcasts播放速度,还能调用具备快进/快退功能的Quicktime来播放Podcasts节目,来看脚本内容:

tell application "iTunes"

    set setupNeeded to false

    --fetch prior selected playlist name and playback rate
    try
        set targetPlaylistName to do shell script "defaults read com.jeffporten.fastpodcast SelectedPlaylist"
        set playbackRate to do shell script "defaults read com.jeffporten.fastpodcast PlaybackRate"
    on error -- probably first run of script
        set setupNeeded to true
    end try

    if setupNeeded is false then -- confirm using last settings
        set userReply to button returned of (display dialog "Play playlist \"" & targetPlaylistName & "\" at " & playbackRate & " speed?" buttons {"Cancel", "Change...", "OK"} default button "OK")
        if userReply is "Change..." then set setupNeeded to true
    end if

    if setupNeeded is true then -- set up new settings
        set listPlaylists to the name of every playlist
        set targetPlaylistName to (choose from list listPlaylists with prompt "Which playlist to play?" without multiple selections allowed and empty selection allowed) as text
        set selectedSpeed to button returned of (display dialog "Playback rate to use?" & return & return & "(½X and 2X correspond to iPod playback speeds, actually 75% and 150%)" buttons {"Custom", "½X", "2X"})
        if selectedSpeed is "2X" then
            set playbackRate to 1.5
        else if selectedSpeed is "½X" then
            set playbackRate to 0.75
        else
            set playbackRate to text returned of (display dialog "Enter a playback speed. (1.0 is normal speed, 2.0 is true double-speed, 0.5 is true half-speed.)" default answer "1.0")
        end if
    end if

    --store settings in a non-AppleScripty way
    do shell script "defaults write com.jeffporten.fastpodcast SelectedPlaylist " & (quoted form of targetPlaylistName)
    do shell script "defaults write com.jeffporten.fastpodcast PlaybackRate " & (quoted form of (playbackRate as text))

    --actually do the playback in QuickTime Player
    set targetPlaylist to playlist targetPlaylistName
    set trackList to tracks of targetPlaylist
    repeat with i from 1 to count trackList
        set thisTrack to item i of trackList
        set podcastName to album of thisTrack
        set thisLoc to location of thisTrack
        set thisDuration to duration of thisTrack

        tell application "QuickTime Player"
            activate
            open thisLoc
            play document 1

            set rate of document 1 to playbackRate

            --if some podcasts should never be rate-altered, delete last line and use this instead
            --if (podcastName does not contain "Onion") then set rate of document 1 to 1.5

            --or for multiple podcasts, add as many of these as you like before "then set rate":
            --and (podcastName does not contain "someOtherPodcast") 

            set nextTrack to false
            set j to 0

            --if the QTP player is manually ended by dragging the slider to the end, automatically starts next podcast
            --if QTP player is closed, script errors out of existence
            --otherwise, when playback is finished, script will close the QuickTime Player document and open the next track in the playlist
            repeat until nextTrack is true
                delay 2
                if current time of document 1 ≥ duration of document 1 then set nextTrack to true
            end repeat

            close document 1
        end tell

        --mark the track as played
        set played count of thisTrack to (played count of thisTrack) + 1

        --I use this AppleScript line to set the rating of the podcast track to one star, which I delete later from a smart playlist
        --set rating of thisTrack to 20
    end repeat
end tell

粘入Applescipt,点击“运行”

 

在第一个弹出框中选择播放速度,有1/2X和2X两种,分别是实际速度的75%和150%

 

或是选择“Custom”自定义速度,中间会让你选择播放列表,选择“Podcasts”即可,输入以0.5为增量的数值可以定义自己需要的快进速度

 

确认点“OK”

 

定义的速度会立即通过Quicktime实现,在恢复普通播放速度后,你还可以使用Quicktime的快进/快退键控制播放进程。

 

一张图帮你快速了解 Apple Watch 相关信息

腾讯·看图 for macOS:符合国人使用习惯的图片浏览软件

PhoneClean:iPhone垃圾清理神器

Web2App:瞬间将网站做成 Mac App

如何让微信打飞机一次打出8颗炮弹@How to – iPhone

有道云笔记 for Mac 2.0 发布:首次支持 Markdown

暂无评论
24小时热文
114868次阅读
15259次阅读
10703次阅读
刚刚被浏览过的文章
3397次阅读
1846次阅读
168次阅读
随机显示站内文章
软件下载频道