RemoteShow.PAL

{ About:
   This script will play a remote show inside SAM
   The show starts at a specified time, and then ends at
   another specified time.
   
   The script also contains some error-correction code
   that will attempt to connect to the stream up to 20 times
   in case it goes down. We schedule one song between each attempt.

   Usage:
    a) Comple configuration below and start PAL script.
    b) If this show is only in certain days you will need to modify the script to
       only queue the show up during these days.
       See the DayOfWeek function.
}
{ CONFIGURATION }
{==================================================}
const ShowURL   = 'http://205.188.234.38:8002/';
const StartTime = '01:01:00';
const EndTime   = '01:05:00';

{ IMPLEMENTATION }
{--------------------------------------------------}
var T : Integer;
PAL.Loop := True;

{Wait for the show to start}
PAL.WaitForTime(StartTime);

{Add show to queue}
Queue.Clear;
Queue.AddURL(ShowURL,ipTop);

{Fade to show}
ActivePlayer.FadeToNext;

{Precautions - if there is a brief disconnect or server problem,
then we would want to retry a few times to get back to the show.
To do this we place the URL quite a few times in the queue, followed
by some normal programmming. That way we will try and reconnect until
the end of the show}

T := 0;
while T < 20 do
begin
  Queue.AddURL(ShowURL,ipBottom);
  CAT['Tracks'].QueueBottom(smLRP,EnforceRules);
  T := T + 1;
end;



{Wait for show to end}
PAL.WaitForTime(EndTime);

{Clear queue}
Queue.Clear;

{Fade to normal programming}
ActivePlayer.FadeToNext;

{--------------------------------------------------}