要在公司中分享一个电影,为了能够简单的播放一些电影的片段,使用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 tell end tell
打开电影后自动全屏播放,等待一段时间后退出全屏并暂停。
由于MPlayerX没有close方法,需要在播放完成之后手动关闭播放器。