MediaMonkey Automation Categorized

From MediaMonkey Wiki
Jump to navigation Jump to search

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

Script is a top-level SongsDB.SDBScriptControl object.

SDB

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:

Player

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

MainTracksWindow

SDB.MainTracksWindow is an SDBTracksWindow object. It gives access to the track entries shown in MediaMonkey's main window.

MainTree

SDB.MainTree is an SDBTree object. It gives access to the nodes in the tree in MediaMonkey's main window.

Related to MainTree are these properties:

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, and any other value with return an error indicator. These IDs can be used to access the collection object from the list of collections found in SDB.Collections.

Songlist properties

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).

UI

SDB.UI is an SDBUI object. This object provides access to specific aspects of the MediaMonkey UI, such as the menus, options dialog, property sheets, etc.

Progress

SDB.Progress is an SDBProgress object. This object is used to initialize, update, and terminate a progress display in the MediaMonkey main window.

WebControl

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.

Library properties

Database

SDB.Database is an SDBDatabase object.

Collections

SDB.Collections is an SDBCollections object, which is just a list of the defined collections. This object has only two members: Count and Item(). Item() returns an SDBCollection object.

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

CommonDialog

SDB.CommonDialog is an SDBCommonDialog object.

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:

  • PlaylistByTitle
  • PlaylistByID

Downloader

SDB.Downloader is an SDBDownloader object.

Device

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.

IniFile

SDB.IniFile is an SDBIniFile object.

Registry

SDB.Registry is an SDBRegistry object.

Settable properties

Readable properties

Status properties

Path properties

Version properties

These allow querying of the MediaMonkey version.

Methods

ProcessMessages CreateTimer MessageBox SelectFolder Format toASCII IsKnownFiletype Localize LocalizedFormat LocalizeGen RefreshScriptItems RegisterIcon RegisterIconHandle