How to control "Mplayer OSX Extended" with Sofa Control?
The codes in the below box is a script to control "MPlayer OSX Extended" with Sofa Control. You can use it for free! The steps to install is easy:
The codes in the below box is a script to control "MPlayer OSX Extended" with Sofa Control. You can use it for free! The steps to install is easy:
Step 1: Save below codes to any file named *.sofa
Step 2: click menu items of Sofa Control: Script/Installed Scripts
Step 3: in the Window "Scripts", drop down the icon gear
Step 4: in Step 3, you should see the menu item "Import Script..."
Step 5: choose the script named *.sofa in Step 1
Follow the steps in above, and you will be happy to control MPlayer OSX Extended.
<?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 " & quoted form of chosenFile
if (chosenFile is not "") then
ignoring application responses
do shell script "open -a " & "\\"" & sApplicationName & "\\"" & " \\"" & chosenFile & "\\""
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>
沒有留言:
張貼留言