Loading a 24Hr Playlist


Our station runs a mix of prerecorded programs and random content. For clarity I have separate playlists for each type.
The schedule playlist has fixed-time containers for these programs, and it spans a whole day. These containers aren’t necessarily an hour long or starting on the hour - they vary. (Scripting the interactions between the two playlists looks achievable).

I found the only way to manage the 24hr schedule playlists is to assume they start at midnight. Loading these automatically in the on-air PC is easy using an Event that runs at midnight.

My problem is when another instance starts at another time in a different studio. I understand that I have to briefly shift the internal clock in order to load a playlist that nominally starts in a different hour. Using the Config utility I can create a Startup Action to do this, but only with a fixed offset from the current time. This does work for a “one off” if the offset puts the internal clock in the 00:00 - 01:00 hour. But there’s no option to set an absolute time cf. a relative (offset) time.

So that leaves the “On Load” handler in a background script, presumably using IAction, and dynamically calculating an offset from the current time when the mAirList instance starts. The 6.0 Scripting Help file only lists 4 “Set” properties for IAction - Options, PlayList, TimeOffset, and Title. Browsing the StartupActions.mla file shows another property (Action Class) that the Help doesn’t mention

I’d appreciate an example of how one scripts an Action that loads a Playlist. (Or a suggestion for a different way to solve this problem!)



Not sure if I got everything right… So when you say you scheduled a 24hrs playlist at midnight, does it mean that you are using mAirListDB, and the entire day is in the 00 hour (with the 01 etc. hours left empty)?

That would be perfectly OK (and the recommended way to overcome the default hourly grid). But it also means that you cannot easily load a particular part of the playlist. Instead, you have to load the entire day, and then skip all items that have (supposedly) run before the current time. So when you open the playlist at 08:00, mAirList should actually remove the first 8 hours worth of items.

There is actually an option for that in the action configuration (skip to current time). But you are right, there is currently no way to tell mAirList to load a particular hour of the current day, it will always load the current hour (or the next hour, or whatever the offset is).

But actually you can just use this simple script instead:

  pl: IPlaylist;

  // Fetch 00 playlist from database
  pl := Database(0).GetPlaylist(trunc(now), 0);

  // Skip all items before current time

  // Load into playout

“trunc(now)” is the 00 hour of the current day. (Delphi’s TDateTime type is actually a floating point number, with the integer part representing the date, and the fractional part the time. trunc() will just remove the fractional part.)

SkipToTime removes all items scheduled before the current time.

And the last command will just load the result into the playout.

Hi Torben,

Thanks - that worked!

To confirm your assumptions - yes, we are using mAirListDB, and the entire day’s program grid is in the midnight - 01:00am slot. So the other 23 hours are not used.

I did tweak the code a little for our particular case, with the separate playlists for the program grid and the random content that fills the gaps between programs. The latter does run the conventional day of 24 x 1hr slots.

SchedulePlayList: IPlayList;


// Second parameter here is 1, not 0, as we’re using a sub-playlist, not the Master.
SchedulePlayList := Database(0).GetPlayList(Trunc(Now), 1);

// Skip all items before the current time.

// Didn’t use CurrentPlayList here as I assumed that means the playing one. (True??)
// Much of the time mAirList will be in manual, not Auto, so we can’t assume a playlist will be active.
// I took a guess that the function “Playlist” returned the zero-based “list” of GUI playlist objects.
// We wanted to specifically fill the first of our pair, not the second. Luck was with me…


I did initially try this in the OnLoad handler in a background script, but it didn’t work. On a hunch I delayed it 5 seconds with a timer, and that succeeded. So it seemed the GUI was not fully initialised at OnLoad. The final version runs the code in a standalone script called by an AfterStartup Action via the Config utility.

Thanks for this simple and elegant solution,


No, it refers to the number of the “Playlist” (handling) object, in case you have configured multiple sets of playlists/players in the config (config app -> Playlists -> Number of playlists).

In case you have only a single one, as 99/100 users have, CurrentPlaylist and Playlist(0) are the same thing.

If you have multiple playlists, CurrentPlaylis will refer to the one that the script was invoked from. For example, when you run the script as part of an Action on Start from an item from Playlist 2, CurrentPlaylist will be identical to Playlist(1). (In scripts. all indices are 0-based.)