Scripting-Hilfe: Prozeduren

So umfangreich die Funktionen in mAirList auch sind, so fehlt doch immer wieder mal das eine oder andere Feature für den gewünschten Zweck. Macht aber nichts, denn genau zu diesem Zweck gibt es die Scripting-Engine, mit welcher die Möglichkeiten in mAirList noch wesentlich umfangreicher werden als ohnehin schon. Also:

Prozeduren

Mit jeder Version von mAirList wird Background Script Template.mls eine Aufzählung der zur Verfügung stehenden Prozeduren in mAirList Script, ausgeliefert, die sich im Programmordner (C:\Programme (x86)\mAirList n.m\) befindet. Aus gutem Grunde ebendort – wird sie doch von Zeit zu Zeit um einige nützliche Funktionen erweitert und ist dann stets aktuell und mit der verwendeten Version kompatibel. Da der Aufenthaltsort dieser Liste aber doch sehr versteckt ist und manche Benutzer von deren Existenz womöglich noch nichts gehört haben, veröffentliche ich sie an dieser Stelle. Ich werde versuchen, sie stets auf dem neuesten Stand zu halten – im Zweifel (ältere mAirList-Versionen!) ist jedoch die Liste aus dem Programmordner heranzuziehen.

Hier also Background Script Template.mls der Version 6.2:

// Called when script is loaded
procedure OnLoad;
begin
end;

// Called when script is unloaded
procedure OnUnload;
begin
end;

// Called after mAirList startup
procedure OnStartup;
begin
end;

// Called before mAirList shutdown
procedure OnShutdown;
begin
end;

// Called when mAirList goes ON AIR
procedure OnOnAir;
begin
end;

// Called when mAirList goes OFF AIR
procedure OnOffAir;
begin
end;

// Called when cartwall window becomes visible
procedure OnCartwallShow;
begin
end;

// Called when cartwall window becomes invisible
procedure OnCartwallHide;
begin
end;

// Called when automation is enabled
procedure OnAutomationOn(PlaylistIndex: integer);
begin
end;

// Called when automation is disabled
procedure OnAutomationOff(PlaylistIndex: integer);
begin
end;

// Called when (playlist) player is started
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
end;

// Called when (playlist) player is stopped
procedure OnPlayerStop(PlaylistIndex: integer; PlayerIndex: integer; Duration: TTimeValue; Item: IPlaylistItem);
begin
end;

// Called when (playlist) player reaches EOF warning point (default: 10s before end)
procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer);
begin
end;

// Called when (playlist) player changes its state
procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
end;

// Called when (playlist) player enters PFL
procedure OnPlayerPFLOn(PlaylistIndex: integer; PlayerIndex: integer; PFLCount: integer);
begin
end;

// Called when (playlist) player leaves PFL
procedure OnPlayerPFLOff(PlaylistIndex: integer; PlayerIndex: integer; PFLCount: integer);
begin
end;

// Called when the cartwall switches its on air mode (on air, off air, PFL)
procedure OnCartwallOnAirModeChange(OldMode, NewMode: TCartwallOnAirMode);
begin
end;

// Called when the user switches between pages/tabs in the cartwall.
// OldPage and/or NewPage can be nil, indicating that no tabs were/are open.
procedure OnCartwallActivePageChange(OldPage: ICartwallPageControl; NewPage: ICartwallPageControl);
begin
end;

// Called when the state of a player on the current cartwall page changes
// (or the user switches to another page).
procedure OnCartwallPlayerStateChange(PlayerIndex: integer;
  OldState: TPlayerState; NewState: TPlayerState;
  Item: IAudioCartwallItem; PlaylistItem: IPlaylistItem;
  OnAirMode: TCartwallOnAirMode);
begin
end;

// Called when cart player is started
procedure OnCartwallPlayerStart(PlayerIndex: integer; Item: IAudioCartwallItem; PlaylistItem: IPlaylistItem);
begin
end;

// Called when cart player is stopped
procedure OnCartwallPlayerStop(PlayerIndex: integer; Item: IAudioCartwallItem; PlaylistItem: IPlaylistItem; Duration: TTimeValue);
begin
end;

// Called when cart player reaches EOF warning point
procedure OnCartwallPlayerEOFWarning(PlayerIndex: integer; Item: IAudioCartwallItem; PlaylistItem: IPlaylistItem);
begin
end;

// Called when on-air playback of an item (in any player) begins
procedure OnItemStart(Item: IPlaylistItem; Region: byte; OnAir: boolean; UniqueID: string);
begin
end;

// Called when on-air playback of an item (in any player) ends
procedure OnItemStop(Item: IPlaylistItem; Region: byte; OnAir: boolean; UniqueID: string; Duration: TTimeValue);
begin
end;

// Called when playback passes a cue marker
procedure OnItemCueMarker(Item: IPlaylistItem; MarkerType: TCuePositionType);
begin
end;

// Called when metadata is received from a (relayed) stream
procedure OnItemMetadata(Item: IPlaylistItem; Metadata: string);
begin
end;

// Called when any player, cue editor, mix editor... enters PFL
// PFLCount is the number of active PFL sources
procedure OnPFLOn(Item: IPlaylistItem; PFLCount: integer);
begin
end;

// Called when any player, cue editor, mix editor... leaves PFL
// PFLCount is the number of active PFL sources
procedure OnPFLOff(Item: IPlaylistItem; PFLCount: integer);
begin
end;

// Called when cue editor, mix editor... (but not a player) starts playback
// ExtPFLCount is the number of active such ExtPFL sources
procedure OnExtPFLOn(Item: IPlaylistItem; ExtPFLCount: integer);
begin
end;

// Called when cue editor, mix editor... (but not a player) stops playback
// ExtPFLCount is the number of active such ExtPFL sources
procedure OnExtPFLOff(Item: IPlaylistItem; ExtPFLCount: integer);
begin
end;

// Called when playlist runs empty during automation
procedure OnPlaylistEmpty(PlaylistIndex: integer);
begin
end;

// Called when a remote command is received from any remote control
procedure OnExecuteCommand(Command: string);
begin
end;

// Called when messages are added to the System Log.
// Be careful what you do here, try not to raise exceptions or use
// SystemLog here, or you might end up in an infinite loop.
procedure OnSystemLog(Category: TLogCategory; Message: string);
begin
end;

// Called every x milliseconds
// Start in OnLoad with: EnableTimer(x);
// Stop with: DisableTimer;
procedure OnTimer;
begin
end;

// Called when RuntimeData (global variables shared among scripts) change.
// Set data with SetRuntimeData(key, value);
procedure OnRuntimeDataChange(Key, Value: string);
begin
end;

// Called when data is received from a serial port; the serial port must
// be opened first, either manually, or by adding a dummy "Serial port"
// remote to the config
procedure OnSerialData(Port: string; Data: AnsiString);
begin
end;

// Called when a command is received from an SAS remote
procedure OnSASCommand(Remote: ISASRemote; Command: byte; Data: string);
begin
end;

// Called when an SAS GPI goes ON
procedure OnSASGPIOn(Remote: ISASRemote; GPI: byte);
begin
end;

// Called when an SAS GPI goes OFF
procedure OnSASGPIOff(Remote: ISASRemote; GPI: byte);
begin
end;

// Called when an SAS sources goes PFL ON
procedure OnSASPFLOn(Remote: ISASRemote; SourceName: string);
begin
end;

// Called when an SAS sources goes PFL OFF
procedure OnSASPFLOff(Remote: ISASRemote; SourceName: string);
begin
end;

// Called when a MIDI message is received
procedure OnMidiMessage(Device: integer; Status, Data1, Data2: byte);
begin
end;

// Called when a MIDI sysex is received
procedure OnMidiSysex(Device: integer; Data: string);
begin
end;

// Called when Voice Track Recorder is opened
procedure OnVTOn;
begin
end;

// Called when Voice Track Recorder is closed
procedure OnVTOff;
begin
end;

// Called when a volume slider is moved in Voice Track Recorder
// Volume is in dB. Source is either "GUI" or "REMOTE".
procedure OnVTVolume(Player: string; Volume: single; Source: string);
begin
end;

// Called when an encoder input is turned on or off
procedure OnEncoderInputToggle(Input: TEncoderInput; NewState: boolean);
begin
end;

// Available in DHD module:

{

procedure OnDHDCommand(Remote: IDHDRemote; ID: cardinal; Len: integer; Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7: byte);
begin
end;

procedure OnDHDFaderOn(Remote: IDHDRemote; FaderNo: integer; State: boolean);
begin
end;

procedure OnDHDFaderPFL(Remote: IDHDRemote; FaderNo: integer; State: boolean);
begin
end;

procedure OnDHDFaderLevel(Remote: IDHDRemote; FaderNo: integer; Level: SmallInt);
begin
end;

}

// Available in REST module:

{

// Called when a request is made to the REST server
procedure OnRESTRequestRaw(Request: TRawRESTRequest; var Response: TRawRESTResponse);
begin
end;

// Called when a JSON request is made to the REST server
procedure OnRESTRequest(Request: TRESTRequest; var Response: IPersistentStorage);
begin
end;

}

begin
end.

Aufgezählte Grüße

TSD

1 Like

Es gibt ab V6.2 Snapshot 4112 neben dem alten EnableTimer/DisableTimer nun auch ein Variante EnableTimerEx/DisableTimerEx, bei der man zusätzlich eine ID übergeben kann. Damit lassen sich dann mehrere Timer gleichzeitig definieren.

EnableTimerEx('bla', 1000);
EnableTimerEx('blup', 2000);

Für die Verarbeitung verwendet man dann die neue Funktion OnTimerEx :

procedure OnTimerEx(ID: string);
begin
  if ID = 'bla' then begin
    // ...
  end
  else if ID = 'blup' then begin
    // ...
  end;
end;

Das alte OnTimer existiert weiterhin und funktioniert wie gewohnt. Danke, Torben!

1 Like

From V6.2.6 on there is a new procedure for people with DHD consoles:

// Available in DHD module:

{

procedure OnDHDLogic(Remote: IDHDRemote; LogicNo: integer; State: boolean);
begin
end;

}


Edit: Ach, der Thread ist ja auf deutsch! Na, Ihr werdet’s auch so verstehen …

2 Likes

Kleine Ergänzung zur procedure OnRuntimeDataChange: Die mit

SetRuntimeData(key, value);

gesetzte Variable kann in Skripten auch gezielt abgerufen werden, z. B. mit:

NewVariable := GetRuntimeData(key);

Der entsprechende Abschnitt in der Datei Background Script Template.mls könnte also geändert werden in:

// Called when RuntimeData (global variables shared among scripts) change.
// Set data with SetRuntimeData(key, value);
// Retrieve data with GetRuntimeData(key).
procedure OnRuntimeDataChange(Key, Value: string);
begin
end;


Ergänzte Grüße

TSD

Neue Prozeduren ab v6.3.6:

// Called when Mix Editor window becomes visible
procedure OnMixEditorShow;
begin
end;

// Called when Mix Editor window becomes invisible
procedure OnMixEditorHide;
begin
end;

// Called when a Cue Editor window becomes visible
procedure OnCueEditorShow;
begin
end;

// Called when a Cue Editor window becomes invisible
procedure OnCueEditorHide;
begin
end;


Dankbare Grüße

TSD

Endlich Schluß mit dem ständigen Polling zur Anzeige des Encoderstatus:

procedure OnEncoderConnectionStateChange(Connection: IEncoderConnection; OldState, NewState: TEncoderConnectionState);
begin
end;

Hier gibt es ein kleines Beispiel wie es funktioniert.

Die Prozedur OnPlayerEOFWarning ist leider von Hause aus ohne die Variable Item, also dem Playlistelement, welches EOF ausgelöst hatte, auf den Markt gekommen. Dies nachträglich zu ändern wäre zwar möglich, führte aber zu Inkompatibilitäten bei allen (!), die ihre Skripte daraufhin nicht anpassen.

Wer innerhalb dieser Prozedur das Item unbedingt benötigt, der kann „mit der Hand“ trotzdem darauf zugreifen:

// Called when (playlist) player reaches EOF warning point (default: 10s before end)
procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer);
var
  Item: IPlaylistItem;
begin
  Item := PlaybackControl(PlaylistIndex).GetPlayer(PlayerIndex).GetItem;
  // Carry on with the code from here
end;

2 Likes