給QuickTime播放器添加快進x秒,快退x秒

前言

蘋果自帶的 QuickTime Player 是一款功能強大的媒體播放器,但在日常使用中,我們可能會發現它缺少了一個非常實用的功能:即通過方向鍵實現快進/快退。這一功能在大多數播放器中都是標配,但在QuickTime Player中卻未能直接提供。為了滿足這一需求,我們可以通過一些額外的設置和腳本編寫,來為QuickTime Player增添這一便捷功能。

操作步驟

1. 打開OS X自帶的"自動操作"軟件

首先,我們需要在Mac的OS X系統中找到并打開 "自動操作"(Automator) 這款軟件。這款軟件允許我們創建各種自動化任務和快捷操作,非常實用。

2. 設置快捷操作的基本參數

"自動操作" 軟件中,我們需要選擇創建一個新的 "快捷操作"(Quick Action) 。隨后,在 "工作流程收到當前" 的設置中,選擇 "沒有輸入" ,這意味著我們的快捷操作不需要接收任何外部輸入。接著,在 "應用程序" 選項中,選擇 "QuickTime Player" ,這樣我們的快捷操作就只會對 QuickTime Player 生效。

3. 添加運行AppleScript動作

在左側的資源庫面板中,我們可以找到各種可用于自動化任務的動作。在這里,我們需要找到并拖拽 "實用工具" 中的 "運行AppleScript" 動作到右側的工作流程區域。

4. 編寫AppleScript代碼

在拖拽完 "運行AppleScript" 動作后,會出現一個編輯框供我們編寫AppleScript代碼。這里我們需要編寫兩個腳本,一個用于快進10秒,另一個用于快退10秒。以下是這兩個腳本的代碼:

快進10秒腳本

on run {input, parameters}
    set step to 10
    tell application "QuickTime Player"
        if front document exists then
            if ((current time of front document) + step) ≤ (duration of front document) then
                set (current time of front document) to ((current time of front document) + step)
            else
                set (current time of front document) to (duration of front document)
            end if
        end if
    end tell
    return input
end run

快退10秒腳本 (要從自動操作中在新建一個,對應這個快退)

on run {input, parameters}
    set step to 10
    tell application "QuickTime Player"
        if front document exists then
            if ((current time of front document) - step) ≥ 0 then
                set (current time of front document) to ((current time of front document) - step)
            else
                set (current time of front document) to 0
            end if
        end if
    end tell
    return input
end run

注意,我們需要分別創建兩個快捷操作來對應這兩個腳本

5. 保存服務

完成腳本編寫后,我們需要保存這個快捷操作。保存后,打開QuickTime Player,在菜單欄中的“服務”列表中就能看到我們剛剛創建的服務了。但此時,這些服務只能通過點擊來運行,還不夠便捷。

6.設置快捷鍵

現在操作起來不方便,可以給這兩個腳本設置快捷鍵

偏好設置->鍵盤->鍵盤快捷鍵 左邊選中”服務“,右邊就看到”通用“中有我們剛才新增的快進、快退,旁邊有設置快捷鍵按鈕

注意,由于系統快捷鍵可能存在沖突,所以在設置快捷鍵時需要確保所選的快捷鍵組合在當前系統中未被其他功能占用。

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容