CreateHookContainer - Automate the creation of Hooks. - V 1.0 RELEASED

Hello erveryone,

I’m currently working on a script which will do the following tasks :

  • Checking each file of a playlist
  • Determine if the item is a song
  • If it’s a song, check if a hook point is set
  • Add this hook-item in a container
  • Add this container in the playlist.

We can also imagine adding on the top of the container a pre-recorded element such as ‘In this hour, you’ll get …’. Everything to give more power on your radio when there is no DJ on air.

We could imagine to place this script just after the ‘Top of Hour’ Jingle.

I’ve taken the liberty of adapting parts of available scripts on this forum. I would like to thanks here all those authors.

Here is the first version of this script.

Here is my code :

[code]// CreateHookContainer - Script to automate the creation of Hook Container based on a playlist. - V 1.0
// Written by Alexis
// Some parts of this script based on IVP-MarkEndings.
// Written by Cad Delworth, Leith FM, Edinburgh, Scotland
// http://www.leithfm.co.uk
// And also Add advertisements and news
// by Vincent Volmer and Cad Delworth

const
// Name of script, used as a prefix to all SystemLog messages
// If you change this, keep a colon and space as the last two characters.
SCRIPTNAME = 'CreateHookContainer: ';

// Minimum effective duration of a song (default: 900 million, =90 seconds)
SONG_MIN_LENGTH = 900000000;

// Variables
var
i, iItemCount, iMax: integer;
i64Duration: int64;
sArtist : string;
sMessage, sPlaylist, sTitle: string;
currentItem, ItemHook, ItemHook2: IPlaylistItem;
ads: IContainerPlaylistItem;
adsPlaylist, newPlaylist: IPlaylist;
adsContainerAsPlaylistItem, piNews: IPlaylistItem;
sFileName: string;
i64HookIn, i64HookFade, i64HookOut: int64;

procedure MarkupCurrentPlaylist;
begin

// Reset counters etc.
iMax := iItemCount - 1;

// Display our start up message
SystemLog(SCRIPTNAME
+ ‘Checking the playlist, looking for songs with Hooks.’);

// Step through each item in the current (selected) Playlist
for i := 0 to iMax do
begin

// Create a local reference to the current item
// This makes all subsequent code easier to read and slightly faster to process
currentItem := CurrentPlaylist.GetItem(i);

// Store the current item’s Artist, Title, and Effective Duration
sArtist := currentItem.GetArtist;
sTitle := currentItem.GetTitle;
i64Duration := currentItem.GetEffectiveDuration;

// Is this a song?
if i64Duration >= SONG_MIN_LENGTH then
begin

// Add the song to the container and set it to a hook.

ItemHook := IPlaylistItem(currentItem).Clone;

ads.GetPlaylist.Add(ItemHook);

i64HookIn := ItemHook.GetCuePosition(ptHookIn).GetValue
i64HookFade := ItemHook.GetCuePosition(ptHookFade).GetValue
i64HookOut := ItemHook.GetCuePosition(ptHookOut).GetValue

ItemHook.GetCuePosition(ptCueIn).SetValue(i64HookIn);
ItemHook.GetCuePosition(ptStartNext).SetValue(i64HookFade);
ItemHook.GetCuePosition(ptCueOut).SetValue(i64HookOut);

SystemLog(SCRIPTNAME + ‘Item ’
+ IntToStr(i + 1)
+ ’ (’
+ Trim(currentItem.GetTitle)
+ ’ / ’
+ Trim(currentItem.GetArtist)
+ ') ’
+ ‘.’);

end;

end; // of for… loop

// All Playlist items processed, inform user

SystemLog(SCRIPTNAME + ‘Checking done.’);

end;

// MAIN CODE STARTS NOW
begin

// Store the current Playlist number as a string, for SystemLog messages
sPlaylist := IntToStr(CurrentPlaybackControl.GetIndex + 1);
iItemCount := CurrentPlaylist.GetCount;

// Create a new Container Item
ads := Factory.CreateContainerPlaylistItem;
// create a copy of the reference as an IPlaylistItem interface
adsContainerAsPlaylistItem := IPlaylistItem(ads);

// Launch the script
MarkupCurrentPlaylist;

// Add Container and change his title
adsContainerAsPlaylistItem.SetTitle(‘Hook Container’);
// Add Container PlaylistItem to current Playlist
CurrentPlaylist.Add(adsContainerAsPlaylistItem);

end.[/code]

Please fell free to give me any comment or remarks.

Thank you for your help.
Cheers,
Alexis.

PS : You can also find the .mls file if it’s easier for you to work on.


CreateHookContainer.mls (3.28 KB)