Sequence of Episodes

Based on 97 episodes of Chickenman


{ Comments:

This script is way complex. Please don’t email me looking for help…. unless you include
vast amounts of Benjamins.

1. It requires you to modify your samdb either in MySql or Firebird. If you can’t do that, forget this script.
2. It requires you to modify the IDv3 tags in your files - maybe. If they are 0 length, they won’t play.
3. File names are important. Very.
4. Each episode here is preceded and followed by a ‘static’ intro, and outro. You WILL need one.
5. Did I mention how complex this script is? Print it out and study it well. Wine or whisky helps. Bud is useless.

This script is designed to play a series of episodes, in this case
Chicken Man. Numbers 1 to 97. Each episode is preceeded by the
chickenman intro, and followed by chickenman outro. At various times
there are chickenman promos played in the current music stream.

The important point being the ability to sequence each show so that
even in the event of a power outage - of any duration - the script
will ensure that the correct show in the sequence is played. It will
not simply restart from show number 1. Nor will it play random
epsiodes - which at the least would be confusing to the listener!

The script relies on a number of static things being in place: <———————— IMPORTANT 1. The episodes are loaded into the songlist in strict order so that their IDs are in strict order. This means that it is unlikely that you can add episodes at a later date. When PAL has decent substring handling, then this script can be changed to use the file_name_num, not the ID. Unless I think of something meantime. So with shows like Elberts storylines, this will not work as shows are added at different times, and thus will end up with non sequential IDs. 2. The script relies on a table being added to SAMDB, in my case called 'chickenman' with one field called 'chickenID' that is the same structure as the ID field in songlist. That is, mediumint(9). More IMPORTANT Notes: If you run this script multiple times in setting it up, keep in mind, that if it gets to the point where it has loaded the current show into the queue, it will assume that it is played, and increment the chickenID and store it ready for the next day. When you are ready to 'go live' then go into the SAMDB, open the chickenman table and reset the chickenID to the chickenID of the first show.When you prepare your mp3/wma whatever files, make sure you have valid IDv3 tags on them. If the 'duration' field of the tag is empty - the show wont play. Naturally, where ever I have 'chickenman' as a name, you should change that to suit your situation.Copyright: Dodgey Brothers. Australia. (c) 2000-3000 Code by: Robert Chalmers. robert@quantum-radio.net (UK & Australia) @ShanghaiTimes http://www.quantum-radio.net, http://www.shanghaitimes.uk, http://www.chalmers.com.au In the Lord I trust, everyone else pays cash. }function ActivePlayer:TPlayer; forward; //Since the fade is a function it has to be //forward declared .So the PAL script knows it exists. PAL.Loop := True; // Make sure it all keeps running // Variables var mytime : DateTime;var I : integer = 500; // iterations through loop var J : integer; var k : integer = 0; // set to 0 to startvar D : TDataSet; // Holds the data set (structure) returned from // the Query var E : DateTime = Queue.ETA; // How long is the queue in seconds? var F : Boolean; // Boolean. On/Off (bit) var S : integer; // Holds the numerical chickenID from the table var V : String; // Holds the filename string and any other strings. var W : String; // Holds chickenman intro fully qualified filename var X : String; // Holds chickenman outro fully qualified filenamevar FirstID : integer; // The ID of the first program in the series, var LastID : integer; // and the ID of the last program in the series. // I've ensured that the programs were loaded into // SAM in strict order, so their IDs are in the // correct order in the songlist. So long as they // don't ever change - !!! this script will work.W := 'F:\My Documents\RadioDaze\StationMusic\Comedy\ChickenMan\chickenman_open.mp3'; X := 'F:\My Documents\RadioDaze\StationMusic\Comedy\ChickenMan\chickenman_close.mp3';FirstID := 8972; // first episode ID LastID := 9068; // last episode ID// chickenID numbers run from 3509 to 3630. These are the IDs from the songlist.// Check if it's the right day/time to play the show. F := false; // Switch off. Not actually used in this script. yet! // Make sure it keeps running// This loop steps through the 97 episodes I have, left over from AFVN days. Thanks Ken Couch. AFVN.while k <= 97 do begin // This next bit could be more compact, but I use this (Thanks Steve) because // it clearly defines what and when I want things to happen. // For example, if you only want a show on Monday - at a time - simply change it // here to what you want. Set the time(s) to play, set the day(s) to play// Make sure that a promo plays up to an hour before the actual show. Depends on // your queue size. Mine keeps four tracks in it. The longest is 26 minutes. // Uh Oh, don't touch that dial, coming up in the next hour.....if (now >= T['14:29:00']) and (now <= T['14:30:00']) and ((DayOfWeek(Now) = Monday) or (DayOfWeek(Now) = Tuesday) or (DayOfWeek(Now) = Wednesday) or (DayOfWeek(Now) = Thursday) or (DayOfWeek(Now) = Friday)) then begin cat['ChickenManPromo'].QueueBottom(smRandom,NoRules); WriteLn('Waiting a moment!'); // Gakkk. Wait at least a minute - or you queue will fill with promos. PAL.WaitForTime(T['+00:02:00']); end; if (now >= T['17:29:00']) and (now <= T['17:30:00']) and ((DayOfWeek(Now) = Monday) or (DayOfWeek(Now) = Tuesday) or (DayOfWeek(Now) = Wednesday) or (DayOfWeek(Now) = Thursday) or (DayOfWeek(Now) = Friday)) then begin // don't forget, this has an end;// Get the correct chickenID from the chickenman table. Remember, this MUST be // set initially with the first track ID that will be used. // The table 'chickenman' has one field called 'chickenID'. Same structure as // the ID field in songlist. // ok, get the show that is slotted to play. D := Query('SELECT chickenID FROM chickenman',[], True); // check it WriteLn(D['chickenID']);S := D['chickenID']; // check it WriteLn(S); // go to songlist and pull the filename with ID = S D := Query('SELECT filename FROM songlist WHERE songlist.ID = :S',[S], True); // stuff it into a variable. ( less typing later on :-) ) V := D['filename']; // check we have the filename WriteLn(V); // Load it into Queue Top ready to play. WriteLn('Load Chickenman'); Queue.Clear(); Queue.AddFile(W,ipTop); // add chickenman_open Queue.AddFile(V,ipBottom); // load the episode Queue.AddFile(X,ipBottom); // load chickenman close below it ActivePlayer.FadeToNext; // fade out what ever is playing and start chickenman. k := k + 1; writeln(k); E := Queue.ETA; WriteLn('Do not pass Go...'); WriteLn(E); PAL.WaitForTime(E); { or if you like, this one. It's just to give the timer enough time to get past 'time to load a file' - otherwise it just loops. Uncomment the lines, and comment the 4 above. } //WriteLn('Wait for 2 tracks'); //PAL.WaitForPlayCount(2); // If you have like 4 songs normally queued, this will then requeue them. // Ok, we have todays show loaded at queue top. increment the chickenID, // uh oh. Is this the last show in the sequence? // If it is, better be carefull to avoid the increment. // If it is the last one, Reset the chickenID to the first one. if S = LastID then begin S := FirstID; WriteLn(S); // stuff it into the chickenman table's 'chickenID' ExecSQL('UPDATE chickenman SET chickenID = :S',[S]); // pull it back and check it. D := Query('SELECT chickenID FROM chickenman',[], True); // check it WriteLn(IntToStr(D['chickenID']) + ', ' + 'Next to play' ); end else // if it's not the last one, just increment as usual begin S := ( S+1 ); // check it WriteLn(S); // stuff it into the chickenman table's 'chickenID' ExecSQL('UPDATE chickenman SET chickenID = :S',[S]); ExecSQL('UPDATE songlist SET songlist.diskID = :S',[S]); // pull it back and check it. D := Query('SELECT chickenID FROM chickenman',[], True); // check it WriteLn(IntToStr(D['chickenID']) + ', ' + 'Next to play' ); end;// wait for another day.....end; // From the first begin, under the 'check what day it is...'// ok, while waiting for next day, plug the show J := J + 1; writeln(J); if J = I then begin //cat['Chicken Man Promos'].QueueBottom(smRandom,NoRules); J := 0; end;if (now >= T['15:29:00']) and (now <= T['15:30:00']) and ((DayOfWeek(Now) = Saturday) or (DayOfWeek(Now) = Sunday)) then begin //cat['Chicken Man Promos'].QueueBottom(smRandom,NoRules); WriteLn('Waiting a moment!'); // Gakkk. Wait at least a minute - or you queue will fill with promos. PAL.WaitForTime(T['+00:02:00']);end; end; function ActivePlayer:TPlayer; begin if DeckA.Status = psPlaying then Result := DeckA else Result := DeckB; end;

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload CAPTCHA.