MediaMonkey Automation Categorized
- 1 MediaMonkey Automation Objects
- 1.1 Script
- 1.2 SDB
- 1.2.1 Player
- 1.2.2 Main Window properties
- 1.2.3 Library properties
- 1.2.4 Utilities and Tools
- 1.2.5 Settable properties
- 1.2.6 Readable properties
- 1.2.7 Methods
MediaMonkey Automation Objects
MediaMonkey's script environment provides two top-level objects accessible from a script running within MediaMonkey: SDB and Script. In an external program (written in a language such as C#) or script (such as in Python), these objects can be accessed by instantiating COM instances.
When a program instantiates a COM instance, the returned object connects directly to the running instance of MediaMonkey. MediaMonkey will be started at the time of instantiation if it is not already running.
Script is a top-level SongsDB.SDBScriptControl object.
SDB is a SongsDB.SDBApplication object. It is the main point of access for MediaMonkey's internals. It has numerous properties which yield objects modeling various components of the program; other properties which yield strings, integers, or flags; and some methods that perform various actions.
SDB is an "evented" object, which means scripts can register functions (callbacks) that will be called when certain events occur within MediaMonkey. This allows the script to respond without having to poll MediaMonkey repeatedly for conditions.
The members of SDB are as follows, arranged by category:
SDB.Player is an SDBPlayer object. It allows access to the player functions: starting, stopping, pausing, skipping and so forth. The player also generates events, which are part of the SDB's event notifications. Only the simplest scripts to control playback will not need to use events.
Main Window properties
Related to MainTree are these properties:
- SDB.VisibleCollectionsCount is the number of collections visible in the Main Tree
- SDB.VisibleCollectionID accepts an index and returns the ID of the collection at that item.
So if VisibleCollectionsCount returns 3, VisibleCollectionID(0) will return the ID of the first visible collection, VisibleCollectionID(2) will return the ID of the third (and last) visible collection; given an index outside that range, VisibleCollectionID will return an error indicator. The returned ID can be used to find the collection object from the list of collections found in SDB.Collections.
Related to MainTracksWindow and MainTree are these properties, each of which yields an SDBSongList that can be queried for Count and individual Items, and other information.
- SDB.AllVisibleSongList is the list of songs visible in the MainTracksWindow
- SDB.SelectedSongList is the list of selected songs in either the MainTracksWindow or the Now Playing pane, depending on which has focus.
- SDB.CurrentSongList is the same as either AllVisibleSongList (if the focus is on the MainTree) or SelectedSongList (if the focus is on the MainTracksWindow or the Now Playing pane).
SDB.WebControl returns an Object corresponding to the built-in Web Browser panel, which is displayed when the Web node of the MainTree is selected.
Note that the ID of a collection is not its index; given a collection ID (e.g., from SDB.VisibleCollectionID), it is necessary to search this list for a collection with a matching ID to get the desired Collection object.
Utilities and Tools
SDB.Tools is an SDBTools object. It is a utility object which contains a number of methods and a few properties of use to scripts. SDB also has a few properties of its own which are similar to those in Tools:
SDB.Device is an SDBDevice object. It is used to access "portable devices" in the system. It does not correspond to a single device itself, but can be queried for individual devices which can then be operated on.
These properties allow querying of useful paths in the MediaMonkey environment:
These properties allow querying of the MediaMonkey version.
- SDB.VersionHi: integer, e.g. 4
- SDB.VersionLo: integer, e.g. 1
- SDB.VersionRelease: integer, e.g. 3
- SDB.VersionBuild: integer, e.g. 1703
- SDB.VersionString: string, e.g. "4.1.3"