Table of Contents > Scripting |
Ultrasonic Documentation
|
Ultrasonic includes a preliminary set of scripting hooks. You can view the current scripting hooks using Apple's Script Editor application. Launch Script Editor, then go to "File" → "Open Dictionary..." and select Ultrasonic from the list.
Here are a few examples to get you started:
The following JavaScript simply toggles play / pause:
Ultrasonic = Application( "Ultrasonic" ) Ultrasonic.playpause()
The following tremendously useful AppleScript loads the main Play Queue, moves to the second song in the list, loads it to one minute from the beginning of the file, and starts playing the file.
tell application "Ultrasonic" load "Play Queue" next go to time 60 play end tell
The following JavaScript searches my entire library for media that match the search string "ingrid", and then prints the file names of all matches that are longer than four minutes in duration. (It looks like I have some duplicate files for this artist.)
Ultrasonic = Application( "com.figure53.Ultrasonic" ) results = Ultrasonic.searchAllMediaFor("ingrid") console.log( "Results:" ) for ( index in results ) { media = results[index]; if ( media.duration() > 60 * 4 ) // longer than 4 minutes? { console.log( media.fileName() ) } } true
Previous: Introduction
|
Next: OSC API
|