This old wiki is now closed for editing. Articles which are still useful and up-to-date will be transfered to the new Wiki shortly.
For the official documentation, please look at the download page.
Scripting
From mAirListWiki
mAirList has its own built-in Pascal/Delphi-like scripting language, mAirListScript, which you can use to write custom functions to control the behaviour of mAirList, interface with or run external programs, or take action when specified events happen within mAirList, such as a Playlist becoming empty. As well as the mAirList-specific functions, you can use many Delphi functions and classes in your Scripts.
mAirListScript is implemented using RemObjects Pascal Script.
Scripts must be saved as text files. The preferred (and usual) file extension is .mls (mAirListScript). A number of example Scripts are included in the scripts subfolder of your mAirList program folder. More hints, tips, and code samples can be found here in the Wiki.
If you are new to scripting, or just new to mAirListScript, we suggest you start by reading Things You Can Do with Scripts.
Contents |
Ordinary Scripts and Notification Scripts
There are two types of scripts: Ordinary Scripts and Notification Scripts.
An Ordinary Script is run manually by a RUNSCRIPT filename
command or by clicking Open, Run Script in mAirList's main menu; or is run automatically by the Event Scheduler. Using Configuration, you can add specific Scripts and/or folders containing Scripts to the dropdown menu behind the Actions button in the main toolbar: these (ordinary) Scripts are known as Action Scripts.
A Notification Script is run automatically by mAirList when a specific event occurs, such as program startup, a Player starting, or a Playlist becoming empty. Programmers will recognize this type of Script as an event handler. A Notification Script can react to the detected event by (for example) writing a log file entry, loading an emergency playlist, or updating an HTML page.
Notification Script Tips
Version 1.5.X-2.0.X:
At the beginning of a Notification Script, use the GetNotification
function to obtain a reference to the notification object as an INotification
interface; then use the GetNotificationType
method to examine and test the type of the event which caused the Script to be run.
You can also use the SetNotificationTypes
method when the Script runs the first time, to pre-define one or more event types which the Script should handle; and add code to the Script to 'ignore' other events the next time the Script runs.
You can see a complete sample Script which uses these techniques in Things You Can Do with Scripts.
Version 2.1.X:
A Notification Script is built-on like this:
procedure activity-whitch-executes-the-script(Parameters); begin -->the script content<-- end; begin end.
A reference of all "activities-whitch-executes-the-scripts" and Parameters are written down in the "Notification Script Template.mls" file in the script->notification folder.
The following script is an intelligent "now playing" script designed to update you SHOUTcast server/s and also save a file to your hard-drive which can be FTP'd to your station's website. The script does nothing if the OnAir switch is set to "Off Air".
// Intelligent Now Playing Script v2 // by Charlie Davy // last modified 25th December 2008 // This script examines each audio item played via a Player and performs a task based upon the track's length. // The 3 settings below work for *most* situations, however you can fine-tune them if you wish. // The last.fm links work for most artist/groups - it adds a nice touch, I think. // Update: The OnAir switch is considered within this script, if you are "Off Air", this script does nothing. // If you are "On Air", the script runs as normal. Useful in a multi-studio environment where pre-recorded // shows may interfer with your live "now playing" display! // IMPORTANT!! You MUST rename this file to .mls when adding it to mAirListConfig const IDENT = 900000000; // 90 seconds MUSIC = 900000000; // 90 seconds PRE_REC = 4200000000; // 7 minutes procedure OnPlayerStart(PlayerControl: IPlayerControl; Item: IPlaylistItem); var sl: TStringList; begin if Engine.GetOnAir = False then begin SystemLog('mAirList is in production mode, so no action taken...'); // Let's ignore any track that has the "Exclude from Logging" option enabled end else if (pioNoLogging in Item.GetOptions) then begin sl := TStringList.Create; sl.Add('Sorry, no details available for this item...'); sl.SaveToFile('C:\nowplaying.php'); sl.Free; HTTPGetAsync('http://server:port/admin.cgi?pass=password&mode=updinfo&song=See our website for information'); SystemLog('This item will not be logged...'); // If the track is over 7 minutes, assume it's a pre-recorded programme end else if (Item.GetDuration > PRE_REC) then begin sl := TStringList.Create; sl.Add('Sorry, no details available for this item...'); sl.SaveToFile('C:\nowplaying.php'); sl.Free; HTTPGetAsync('http://server:port/admin.cgi?pass=password&mode=updinfo&song=See our website for information'); SystemLog('This item is a pre-record or longer than 7 minutes...'); // If the track is more than 90 seconds, assume it's a song end else if (Item.GetDuration > MUSIC) then begin sl := TStringList.Create; sl.Add('<a href="http://www.last.fm/music/' + Item.GetArtist + '" title="click here for the last.fm profile for ' + Item.GetArtist + '">' + Item.GetArtist + '</a> - ' + Item.GetTitle); sl.SaveToFile('C:\nowplaying.php'); sl.Free; HTTPGetAsync('http://server:port/admin.cgi?pass=password&mode=updinfo&song=' + Item.GetArtist + ' - ' + Item.GetTitle); SystemLog('Now Playing... ' + Item.GetArtist + ' - ' + Item.GetTitle); // If the track is under 90 seconds, assume it's an advert or jingle // You may wish to comment this section out as sending this info for such a short time may seem pointless! end else if (Item.GetDuration < IDENT) then begin sl := TStringList.Create; sl.Add('More music soon'); sl.SaveToFile('C:\nowplaying.php'); sl.Free; HTTPGetAsync('http://server:port/admin.cgi?pass=password&mode=updinfo&song=More Music Soon'); SystemLog('Playing Adverts or Jingles...'); end; end; begin end.
This script is best placed into the mAirList\Scripts\Notification folder (or a shared folder if you are part of a multi-studio network).