標籤:
要在公司中分享一個電影,為了能夠簡單的播放一些電影的片段,使用AppleScript和MPlayerX的seekto功能來播放指定時間段的電影。
tell application "Finder" open document file "xxx.mkv" of folder "Movies" of folder "vector" of folder "Users" of startup disk using application file "MPlayerX.app" of folder "Applications" of startup disk tell application "MPlayerX" activate pause delay 1 set isFullScreenAfter to false tell application "System Events" try tell front window of (first process whose frontmost is true) set isFullScreen to get value of attribute "AXFullScreen" set isFullScreenAfter to not isFullScreen set value of attribute "AXFullScreen" to isFullScreenAfter end tell end try end tell delay 1 (* seekto 1539*) seekto 1650 play end tell delay 82 tell application "MPlayerX" tell application "System Events" try tell front window of (first process whose frontmost is true) set isFullScreen to get value of attribute "AXFullScreen" set isFullScreenAfter to not isFullScreen set value of attribute "AXFullScreen" to isFullScreenAfter end tell end try end tell pause delay 1 end tellend tell
開啟電影后自動全屏播放,等待一段時間後退出全屏並暫停。
由於MPlayerX沒有close方法,需要在播放完成之後手動關閉播放器。
使用AppleScript播放指定時間的電影片段