FB粉絲按鈕

2009年7月8日 星期三

在 Sofa Control 上控制 MPlayer OSX Extended 的 script


★這篇文章有用嗎?請幫我按“追蹤、分享”!
在 Sofa Control 上控制 MPlayer OSX Extended 的 script
Sofa%20Control.jpg MPlayer OSX Extended Logo
MPlayer OSX Extended 是 Mpalyer OSX 的介面美化及功能加強的版本,其實原來我與 "MPlayer OSX" + "Sofa Control" 一直相處愉快,不過最近在看 *.MKV 檔時,MPlayer OSX 無法支援內鑲字幕,而 MPlayer OSX Extended 支援,所以我就跳糟啦!(可見介紹 威力遙控器 Sofa Control
)但是 Sofa Control 的網站沒有放 MPlayer OSX Extended 的 script,這是不是太不尊重 MPlayer OSX Extended 的支持者啦。問 Google 大神,它也不知道!順便抱怨一下,為什麼 Sofa Control 的網站,也沒有放上 script 的 manual,那叫大家用猜的嗎?所以我就大猜特猜啦!以下的 script for Sofa Control 是參考 VLC 及 Preview 的 script 修改來的,要用的人把這個 script 存成 *.sofa 再滙入就可以使用了。如果自行修改,要記得要重新執行 Sofa Control哦。

<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "file:///System/Library/DTDs/CoreData.dtd">

<database>
<databaseInfo>
<version>134481920</version>
<UUID>CC8DFDB3-18EB-4182-B1B7-CC8C430900D5</UUID>
<nextObjectID>102</nextObjectID>
<metadata></metadata>
</databaseInfo>
<object type="REMOTEAPP" id="z102">
<attribute name="applicationbundleidentifier" type="string">hu.mplayerhq.mplayerosx.extended</attribute>
<attribute name="applicationname" type="string">Mplayer OSX Extended</attribute>
<attribute name="autotakescontrol" type="bool">1</attribute>
<attribute name="lastchangedate" type="date">268670105.72230899333953857422</attribute>
<attribute name="name" type="string">MPlayer OSX Extended</attribute>
<attribute name="scriptcode" type="string">(*
Copyright 2007, Hubert Chan

Description: Open and play movies using MPlayer OSX
Author: Hubert Chan, hfchan@engsoc.org
Product-URL: http://www.mplayerhq.hu
Note: author of this script is not affiliated in any way with the MPlayer OSX project

Mappings:
* plus/minus: MPlayer volume up/down
* plus/minus hold: MPlayer volume up/down
* plus/minus double: jump 1 minute forwards/backwards

* left/right: jump 10 seconds backwards/forwards
* left/right hold: fast backward/forward in current movie (10 second increments)
* play/stop: start/stop playing
* play hold: toggle fullscreen

Settings:
Script Chooser Activation: Fullscreen is activated when MPlayerOSX is started through script chooser

Menu:
* jump forward 10 minutes
* jump backwards 10 minutes
* open... (a file)
* toogle fullscreen
* quit

Notes:
* could not assign "jump 1 minute forwards/backwards" to a double-right/left; the single-right/left always executed before second click was recognized
* "open..." menu option only lists media files (.mov, .avi, .wmv); graphics formats are excluded
* MPlayerOSX has no Applescript support, so to open a file a shell command is executed to open the chosen file with MPlayerOSX
*
*)

global movieFolder
global g_shall_quit
global sApplicationName
set g_shall_quit to false

on rcActivate()
set g_shall_quit to false
set sApplicationName to "Mplayer OSX Extended"
tell application "Finder"
try
set movieFolder to item "Movies" of home as string
set movieFolder to POSIX path of movieFolder
on error
set movieFolder to POSIX path of (home as string)
end try
end tell

ignoring application responses
tell application sApplicationName
activate
end tell
end ignoring
-- above should open MPlayerOSX (if installed) regardless of where it's located on user's filesystem

(*
-- use above to open MPlayerOSX; avoid block below, as end-user would have to select MPlayerOSX first time this is run on their account
tell application "MPlayerOSX"
activate
end tell
*)
if active sofascript is not auto activated then
toggleFullscreen()
end if

tell active sofascript of application "Sofa Control"
-- core actions
tell (make new action with properties {title:"Core Actions"})
make new action with properties {title:"Volume Up", script function:"volumeUp", button:plus pressed}
make new action with properties {title:"Volume Down", script function:"volumeDown", button:minus pressed}
make new action with properties {title:"Volume Up", script function:"volumeUp", button:plus hold}
make new action with properties {title:"Volume Down", script function:"volumeDown", button:minus hold}
make new action with properties {title:"fast forward", script function:"fastForward", button:right pressed}
make new action with properties {title:"fast backward", script function:"fastBackward", button:left pressed}
make new action with properties {title:"faster forward", script function:"fastForwardHold", button:right hold}
make new action with properties {title:"faster backward", script function:"fastBackwardHold", button:left hold}
make new action with properties {title:"play/pause", script function:"togglePlay", button:play pressed}
end tell

-- advanced actions
make new action with properties {title:"Forward 10 min.", script function:"fwdTen"}
make new action with properties {title:"Back 10 min.", script function:"backTen"}
make new action with properties {title:"Open...", script function:"openFile"}
make new action with properties {title:"Fwd 1 min", script function:"fwdOne", button:plus pressed, number of clicks:2}
make new action with properties {title:"Back 1 min", script function:"backOne", button:minus pressed, number of clicks:2}
make new action with properties {title:"Toggle Full Screen", script function:"toggleFullscreen", button:play hold}
make new action with properties {title:"Quit MPlayerOSX Ext.", script function:"quitApplication"}


end tell
end rcActivate

on volumeUp()
simulate keystroke "0"
end volumeUp

on volumeDown()
simulate keystroke "9"
end volumeDown

on fastForward()
simulate keycode 124 -- send right Arrow
end fastForward

on fastBackward()
simulate keycode 123 -- send left Arrow
end fastBackward

on fastForwardHold(holdCounter)
if (holdCounter > 0) then fastForward()
end fastForwardHold

on fastBackwardHold(holdCounter)
if (holdCounter > 0) then fastBackward()
end fastBackwardHold

on togglePlay()
-- send Space
simulate keycode 49
end togglePlay

on toggleFullscreen()
-- send Command-f
simulate keystroke "f" with command
end toggleFullscreen

on fwdOne()
-- send Up Arrow
simulate keycode 126
end fwdOne

on backOne()
-- send Down Arrow
simulate keycode 125
end backOne

on fwdTen()
-- send Page Up
simulate keycode 116
end fwdTen

on backTen()
-- send Page Down
simulate keycode 121
end backTen

on openFile()
choose file of type {"public.audiovisual-content", "dyn.ah62d4rv4ge804450"} from directory movieFolder display type "Media Files"
--choose file from directory movieFolder display type "Media Files"
end openFile

on rcFileNameChosen(chosenFile)
-- display dialog "blah " &amp; quoted form of chosenFile
if (chosenFile is not "") then
ignoring application responses
do shell script "open -a " &amp; "\\"" &amp; sApplicationName &amp; "\\"" &amp; " \\"" &amp; chosenFile &amp; "\\""
end ignoring
end if
end rcFileNameChosen

on quitApplication()
set g_shall_quit to true
tell active sofascript to deactivate
end quitApplication

on rcMenu()
tell active sofascript of application "Sofa Control" to show actions
end rcMenu

on rcDeactivate()
tell application sApplicationName
stop
if g_shall_quit is true then
ignoring application responses
quit
end ignoring
end if
end tell
end rcDeactivate
</attribute>
<attribute name="scriptversion" type="float">1</attribute>
<attribute name="showinappswitcher" type="bool">1</attribute>
<attribute name="userenabled" type="bool">1</attribute>
</object>
</database>

沒有留言:

張貼留言