I’m using this script in mAirlist 4.3
Run it after loading the playlist for the next hour, it will look for the Top of the hour dummy object, and after that will search for 3 songs with hooks and create the container with a opener, middle and closer and then put the the container after top of the hour dummy.
[code]var
i, iItemCount, iMax, iVol, iToth: integer;
i64Duration: TTimeValue;
sArtist : string;
sMessage, sPlaylist, sTitle : string;
currentItem, ItemHook, ItemHook2: IPlaylistItem;
ads: IContainerPlaylistItem;
adsPlaylist, newPlaylist: IPlaylist;
adsContainerAsPlaylistItem, piNews: IPlaylistItem;
sFileName, sOpener, sCloser, sMiddle: string;
i64HookIn, i64HookFade, i64HookOut: TTimeValue;
const SONG_MIN_LENGTH = 900000000;
procedure startMarkup;
begin
for i := 0 to Playlist(0).GetCount -1 do
begin
if Playlist(0).GetItem(i).GetTitle = ‘Top of the hour’ then begin
iToth := i;
SystemLog(Playlist(0).GetItem(i).GetTitle);
break;
end;
end;
end;
procedure MarkupCurrentPlaylist;
begin
// Set values (REPLACE THESE WITH YOUR OWN)
sOpener := ‘Opener.mp3’;
sMiddle := ‘Middle.mp3’;
sCloser := ‘Closer.mp3’;
// Reset counters etc.
iMax := iItemCount - 1;
iVol := 0;
// Display our start up message
SystemLog('Hook: ’
+ ‘Checking the playlist, looking for songs with Hooks.’);
ads.GetPlaylist.InsertFile(0, sOpener, [fitMMD, fitTags, fitNativeTags, fitDuration, fitTilde, fitAutoCue, fitDatabaseLookup]);
// Step through each item in the current (selected) Playlist
for i := iToth + 2 to Playlist(0).GetCount -1 do
begin
// Create a local reference to the current item
// This makes all subsequent code easier to read and slightly faster to process
currentItem := Playlist(0).GetItem(i);
// Store the current item’s Artist, Title, and Effective Duration
sArtist := currentItem.GetArtist;
sTitle := currentItem.GetTitle;
i64Duration := currentItem.GetDuration;
// Is this a song?
if 0 >= 0 then
begin
// Add the song to the container and set it to a hook.
ItemHook := iPlaylistItem(currentItem.Clone);
i64HookIn := ItemHook.GetCuePosition(ptHookIn);
i64HookFade := ItemHook.GetCuePosition(ptHookFade);
i64HookOut := ItemHook.GetCuePosition(ptHookOut);
if (i64HookIn > 0) then
begin
// SystemLog(‘Added’);
ads.GetPlaylist.Add(ItemHook);
if (iVol < 2) then
begin
ads.GetPlaylist.InsertFile(ads.GetPlaylist.GetCount, sMiddle, [fitMMD, fitTags, fitNativeTags, fitDuration, fitTilde, fitAutoCue, fitDatabaseLookup]);
end;
ItemHook.SetCuePosition(ptCueIn, i64HookIn);
ItemHook.SetCuePosition(ptFadeOut, i64HookFade);
ItemHook.SetCuePosition(ptStartNext, i64HookFade);
ItemHook.SetCuePosition(ptCueOut, i64HookOut);
ItemHook.SetArtist('Coming up: '+ currentItem.GetArtist);
iVol := iVol + 1
end;
if (iVol = 3) then
begin
break;
end;
SystemLog('Hook: ’ + ‘Item ’
+ IntToStr(i + 1)
+ ’ (’
+ Trim(currentItem.GetTitle)
+ ’ / ’
+ Trim(currentItem.GetArtist)
+ ') ’
+ ‘.’);
end
end; // of for… loop
// All Playlist items processed, inform user
if (ivol < 3) then
begin
ads.GetPlaylist.Delete(ads.GetPlaylist.GetCount -1);
end;
ads.GetPlaylist.InsertFile(ads.GetPlaylist.GetCount, sCloser, [fitMMD, fitTags, fitNativeTags, fitDuration, fitTilde, fitAutoCue, fitDatabaseLookup]);
SystemLog('Hook: ’ + ‘Checking done.’);
end;
begin
// Create a new Container Item
ads := Factory.CreateContainerPlaylistItem;
// create a copy of the reference as an IPlaylistItem interface
adsContainerAsPlaylistItem := IPlaylistItem(ads);
startMarkup;
MarkupCurrentPlaylist;
adsContainerAsPlaylistItem.SetTitle(‘Coming Up Next’);
Playlist(0).Insert(iToth + 1, adsContainerAsPlaylistItem);
end.[/code]