Hourly Playlists - Loading Script ?

I had this working before, but now I can’t seem to get it to run - Probably something very simple, hence my post on here for the experts! Playlists on our system are hourly, in the format ddmmyy-hh, so today’s playlist for 10am would be 030906-10.m3u - The event “fires”, but doesn’t load the playlist.

Here’s my script file:

begin CurrentPlaylist.Append('D:\Playlists\' + FormatDateTime('ddmmyy-hh', now + 0.04166) + '.m3u'); end.

D:\Playlists\ exists and contains the playlists. So I’m a bit stumped ;( I’m not quite sure how your datetime system works, Torben - is it universal or are you in control of it ? ie: YY would be 06, but YYYY would be 2006 for example. DDD would be Sun, DD is 03… and so on.

Here’s some reference for FormatDateTime (it’s a Delphi built-in function which is exported so that you can use it from the scripts):

http://www.delphibasics.co.uk/RTL.asp?Name=FormatDateTime

Your code looks ok so far. Might there be a problem with the Append method? Do other (statically named) playlists work?

By the way, for debugging, you can use the function SystemLog that writes a string to the log area at the bottom of the main window:

begin SystemLog('D:\Playlists\' + FormatDateTime('ddmmyy-hh', now + 0.04166) + '.m3u'); end.

Torben

It says there’s an error in the script…

Invalid Class Typecast

I’ve tried the script with the 2 commands between begin/end - and also with their own begin/end statements. Both produce that error message.

I don’t suppose there’s a way to add these dd mm yy variables to the Load Playlist event, is there ? So in the load playlist window, we have this:

D:\Playlists\ddmmyy-hh.m3u

Or perhaps:

D:\Playlists\%dd%mm%yy-%hh.m3u

ADDITIONAL…
I also cannot get this one to work (same error) with a daily playlist:

[code]var i: integer;

begin
for i := CurrentPlaylist.GetHistoryCount to CurrentPlaylist.GetCount - 1 do
if CurrentPlaylist.GetItem(i).GetTitle = ‘START OF HOUR’ then begin
CurrentPlaylist.AutomationJump(CurrentPlaylist.GetItem(i));
break;
end;
end.[/code]

Our “top of hour” dummy always has the format START OF HOUR 13:00:00 (for 1pm).

I don't suppose there's a way to add these dd mm yy variables to the Load Playlist event, is there ?

Of course there is, but I would like to avoid that. Have you seen all of those possible variables on the FormatDateTime help page mentioned above? I would have to implement manual replacement for al of these. And then, you would have to tell mAirList that it’s the next hour to consider, not the current. Other users might need variables for the current hour … tricky.

You see, all of this is very custom. And the idea is to use scripts for this. Let’s get this working :slight_smile:

Can you please post the complete script (including begin and end) that causes the Invalid Class Typecast error?

Our "top of hour" dummy always has the format [b] START OF HOUR 13:00:00[/b] (for 1pm).

Then you have to compare only the first 13 (= length of “START OF HOUR”) characters of the title to the magic words. You can use the Pascal function “copy” for this:

[code]var i: integer;

begin
for i := CurrentPlaylist.GetHistoryCount to CurrentPlaylist.GetCount - 1 do
if copy(CurrentPlaylist.GetItem(i).GetTitle, 1, 13) = ‘START OF HOUR’ then begin
CurrentPlaylist.AutomationJump(CurrentPlaylist.GetItem(i));
break;
end;
end.[/code]

Torben

I’m obviously missing something (perhaps obvious), but I just used that example you posted and it brings the same error. I have turned-off the PlaylistHistory feature - Is that related ?

So, just to be sure - My script file only contains:

[code]var i: integer;

begin
for i := CurrentPlaylist.GetHistoryCount to CurrentPlaylist.GetCount - 1 do
if copy(CurrentPlaylist.GetItem(i).GetTitle, 1, 13) = ‘START OF HOUR’ then begin
CurrentPlaylist.AutomationJump(CurrentPlaylist.GetItem(i));
break;
end;
end.[/code]

We’d prefer hourly playlists, as it speeds up loading and makes starting automation from another PC or mid-way fairly easy. But when I try both daily+hourly playlists - the script produces this same error message.

Just to be sure - it’s the latest mAirList version you’re using, isn’t it?

Is the “Invalid Class Typecast” error displayed as a message box or in the system log? In case of the latter, it should tell the row and column at which the error occured, just like “[Error] (2:3): …”. What’s the position of that Typecast error?

Torben

Yes, version .22

I can’t seem to get any more info out of that drop-down box… Just invalid typecast. Here’s the first few lines of a playlist, just to show you how it looks:

#mAirList DUMMY 0 START OF HOUR 00:00:00 D:\BUZZ RADIO\GENERIC IDENTS\Buzz Radio - Generic Ident 3.mp3 D:\AUDIO TO IMPORT\Nerina Pallot - Everybody's Gone to War.mp3 D:\GALAXY\Galaxy Songs\Sandi Thom - What If I'm Right.mp3

Weird. All of this works fine here. Maybe the error is caused by some item in the playlist? Does it load fine when appended through the Open menu?

Torben

Yes - Works fine if I use “Run Script” from the Open menu. ?! Here’s my Event dialogue-box - Which fires the event, and yes - the dreaded Typecast Error was present in the error box.

It’s set to 56:30 as I was forcing it to play.

Hm. Then it seems to be an issue related to the event scheduler, rather than an error within the script. I’m at the office right now, rather busy, but I will take a look at it later this day.

Torben

Ok, it’s the event scheduler causing the error message, and it happens with any script executed through an event. I have corrected the error, it will be fixed in 1.5.23 (released tonight).

Torben

Thanks, Torben - As of now (.23), the script loading is working fine…

Whitch is the right source code you’re using? I want to test the script myself :wink:

Thanks,
David

These are my scripts…

Jump To Next Hour
This would run at 58 minutes past, and using the line: [b]#mAirList DUMMY 0 START OF HOUR 16:00:00 /b at the start of each hour, this script checks the first 13 characters from the text: “START OF HOUR” and jumps to the next occurance…

[code]var i: integer;

begin
for i := CurrentPlaylist.GetHistoryCount to CurrentPlaylist.GetCount - 1 do
if copy(CurrentPlaylist.GetItem(i).GetTitle, 1, 13) = ‘START OF HOUR’ then begin
CurrentPlaylist.AutomationJump(CurrentPlaylist.GetItem(i));
break;
end;
end.[/code]

Load Current Hour
eg: “Thu 00 07 09.m3u”

begin CurrentPlaylist.Load('D:\mAirList Files\' + FormatDateTime('ddd hh dd mm', now) + '.m3u'); end.

Load Next Hour
This would run at 58 minutes past the hour, and get the next playlist ready for playout after the current song finishes.

begin CurrentPlaylist.Load('D:\mAirList Files\' + FormatDateTime('ddd hh dd mm', now + 0.04166) + '.m3u'); end.

Enjoy…

So all this scripts are running at XX.58?

Thanks,
David

No… Only 1 of these is required. It depends if you use Hourly or Daily playlists. If using Daily, you’ll want to use the “Jump” script at 58 ish, and a daily “Load Playlist” at 23:58 to load the next day.

The Hourly playlist will just require the “Load Next” playlist at 58 mins. The “Load Current” is just a quick way of loading the current playlist without having to look for it on the hard-drive :wink:

Hi guys.

I’m trying to jump mAirList 2.1.19 (temp fix executable) to a dummy file called “New Hour Starts Here”.

This is the script I’ve tried based on what I’ve read in this topic:

var i: integer;

begin
for i := CurrentPlaylist.GetHistoryCount to CurrentPlaylist.GetCount - 1 do
if copy(CurrentPlaylist.GetItem(i).GetTitle, 1, 19) = ‘New Hour Stars Here’ then begin
CurrentPlaylist.AutomationJump(CurrentPlaylist.GetItem(i));
break;
end;
end.

However all I get in return is an error unknown identifier ‘AUTOMATIONJUMP’.

Any ideas?

Thanks,
Gavin.

Some of the identifiers have changed since the original version of that script. An updated script can be found in this thread: http://forum.mairlist.de/viewtopic.php?t=1127

[code]var i: integer;

begin
for i := 0 to CurrentPlaylist.GetCount - 1 do
if copy(CurrentPlaylist.GetItem(i).GetTitle, 1, 13) = ‘START OF HOUR’ then begin
CurrentPlaybackControl.AutomationJump(CurrentPlaylist.GetItem(i));
break;
end;
end.[/code]

(“CurrentPlaylist” refers to the playlist data, “CurrentPlaybackControl” to the object which handles the data, i.e., which loads, starts, stops players etc.)

Torben

PS: Hint: When posting scripts, please wrap them in the code environment (click the “Code” button above the editor window), it’s much easier to read then, because indentation is preserved.

Ahh success! Thanks Torben.

Is it possible to get mAirList to jump, but wait for the current item to finish?

Thanks for the hint aswell, I thought it may have been code, I wasn’t sure.

Gavin.

I tried to replace AutomationJump with AutomationNext which I just found in the script help documents (under construction). However invalid number of parameters is the error I got. I didn’t think it would be as easy as replacing a word :o)