Insert as Next if File Exists

Dear all,

I am trying to automatically insert a File into playlist as next item if it exists.

As a basic approach I tried the following:

procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer); begin if FileExists('s:\External\Playme.mp3') then begin newItem := Factory.CreateFilePlaylistItem('s:\External\Playme.mp3', [fitAutoCue]); CurrentPlaylist.Insert(CurrentPlaylist.IndexOf(activeItem) + 1, newItem); end; end;

When I try to load the code, mAirlist complains about the number of parameters (obviously for the nerItem:=… line).

I tried to find help about the parameters in the mAirlistScriptingHelp.chm, but there is not text in it (only chapters).

  1. What am I doing wrong in the script ?
  2. Any ideas how to make the scripting help (chm-file) work ?

Can anyone point me in to the right direction?

Thank you,

Christoph

P.S.: This is on mAirList 4.2.3

You can make the help file work by “unblocking it”. Just right click on the file -> Properties and then unblock.

Looks like the second parameter needs to be a boolean (so true or false).


Capture.PNG

2.PNG

This must be a very old copy of the CHM file - the second parameter is not “iLoadData: boolean” anymore, but actually a set of “TFileImportTask” flags, telling mAirList which sources to check for metadata: tags, database, Auto Cue, …

Please regard the CHM file only as a list of available functions. It’s generated directly from my source code, and there is hardly any documentation for the functions, most of which are internal anyway. Feel free to ask questions for a particular problem.

Regarding the error message, it looks like “activeItem” and “nextItem” haven’t been declared - there is no “var” section at all.

The easiest method to find the right insertion point is to use the “GetNextIndex” function - it will return the index of the item that is going to be played next.

procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer);
begin
  if FileExists('s:\External\Playme.mp3') then
    CurrentPlaylist.Insert(CurrentPlaylist.GetNextIndex, Factory.CreateFilePlaylistItem('s:\External\Playme.mp3', [fitAutoCue]));
end;

Thanks Torben and Wiele,

I will try at home.

@Torben: Looks like I coded to much in Perl - no declaration necessary there, when not in “strict mode” :wink:

Christoph

In classic Pascal, everything has a type and must be declared properly :slight_smile: