使用AppleScript播放指定时间的电影片段

要在公司中分享一个电影,为了能够简单的播放一些电影的片段,使用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方法,需要在播放完成之后手动关闭播放器。

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。