Insert Random Ident Help!

Hi guys! We’re still in the dark ages and running 2.2.3 (budget issues!) and I’m having a problem with this script. It is a hybrid of the ‘Random Jingle’ script posted here,3977.0.html by shorty.xs and Charlie’s ‘Now Playing’ script on the Wiki.

What I’m trying to achieve, is a script that will identify the current playing item as music (if it is under 7 mins long) and insert a random ident (script will be run every 8 mins as an event). The script shouldn’t run if an ident (shorter than 90 secs) or a pre-record (longer than 7 mins) is playing.
I know nothing about scripting and haven’t managed to get this to work. I usually seem to get away with looking at the way that other scripts are put together and bodging things together, on this occasion it hasn’t worked! Any pointers would be greatly appreciated!!!

This should all be carried out on the currently playing item.

IDENT = 900000000;	// 90 seconds
MUSIC = 900000000;	// 90 seconds
PRE_REC = 4200000000;	// 7 minutes

var i: Integer;
    ts: TStringList;
    pfad: Array[0..7] of string;

end else if (Item.GetDuration < IDENT) then begin
end else if (Item.GetDuration > PRE_REC) then begin
end else if (Item.GetDuration > MUSIC) then begin

  pfad[0] := 'C:\Ident1.mp3';
  pfad[1] := 'C:\Ident2.mp3';
  pfad[2] := 'C:\Ident3.mp3';
  pfad[3] := 'C:\Ident4.mp3';
  pfad[4] := 'C:\Ident5.mp3';
  pfad[5] := 'C:\Ident6.mp3';
  pfad[6] := 'C:\Ident7.mp3';
  pfad[7] := 'C:\Ident8.mp3';
  i := Random(7);
  CurrentPlaylist.InsertFile(0, pfad[i], eaNone);



Well, assuming you’re using v2.2.3, this would be a good start:

MUSIC = 900000000; // 90 seconds
PRE_REC = 4200000000; // 7 minutes

i: Integer;
itemDuration: int64;
pfad: Array[0…7] of string;


pfad[0] := ‘C:\Ident1.mp3’;
pfad[1] := ‘C:\Ident2.mp3’;
pfad[2] := ‘C:\Ident3.mp3’;
pfad[3] := ‘C:\Ident4.mp3’;
pfad[4] := ‘C:\Ident5.mp3’;
pfad[5] := ‘C:\Ident6.mp3’;
pfad[6] := ‘C:\Ident7.mp3’;
pfad[7] := ‘C:\Ident8.mp3’;

itemDuration := CurrentPlaylist.GetItem(0).GetDuration;

if (itemDuration > MUSIC) and (itemDuration < PRE_REC) then
i := Random(7);
CurrentPlaylist.InsertFile(1, pfad[i]);


What this does is to check the duration of the first item in the playlist, and if that is within the correct range (larger than MUSIC and less than PRE_REC), it will then do the random thing and insert the file you chose.

I’m not 100% sure about the the InsertFile statement (especially in V2!): you’ll note that I changed the zero to a one, so that whatever you insert will become the SECOND item in the Playlist, because the currently playing item is always the top item, right? I also don’t think you need the eaNone bit, but it’s so long since I wrote a script for V2.2.3 that again, I’m not certain, so you might need to replace that bit if it blows up on you.

Hope that’s a starting point for you, anyway.


Thanks for that Cad, I’ll give it a test this afternoon!

Hmmmm, it can’t understand ‘ITEM’ on line 35.
It gives: [Error] (20.35): Unknown identifier ‘ITEM’

It doesn’t work in 3.1 either.

Sorry Chris, that should have read GetItem: it was somewhat late at night when I wrote that!

I’ve corrected that in the post above. :wink:


Still no luck, I get ‘(25:43): Invalid number of parameters’. I’ve tried varying the ‘InsertFile’ thing but it didn’t make the slightest difference! (Line 25, Char 43 is the very last part of the line, why does it report that as the fault???).

The message means there are the wrong number of ‘things’ inside the parentheses. It reports the last character as the problem area because it was expecting more parameters after that.

You’ll probably need to change the line back to this:

CurrentPlaylist.InsertFile(1, pfad[i], eaNone);

In other words, add the eaNone value to the line again.
(To be fair, I did say earlier that I wasn’t sure about that line for v2: the version I gave does work in v3!)

If this change works, but inserts the sweeper in the ‘wrong’ place, change the 1 in InsertFile. Add one to insert further down the playlist, subtract one to insert further up the playlist. Zero is the lowest number allowed.

Hope that helps. :slight_smile:


Awesome, ran it on test this afternoon, it works great!!! Thanks so much for your time!