SayTime.PAL

{ Comments:
  This script started life as the USNews script. Thanks Elbert. I needed your
  input, or this could not have been done.
  
  This script relies on having the associated TIME mp3 files. You should
  have the attachement from the KB. Times.zip  Point your script to where
  you put them.
  
  I am having a few problems with SAM having a little hiccup each time it
  starts a track - not only these time ones. Hopefully your milage is better.
  
  So, unpack the time files, and put this in your PAL list, make
  the suitable adjustments, and every time you set it, this will say the time!
  

}



function ActivePlayer:TPlayer; forward; 
PAL.Loop := True;
 
const TimeHeader  : String = 'C:\Documents and Settings\Robert\My Documents\Radio Daze\Times\';
const TimeHours   : String = 'C:\Documents and Settings\Robert\My Documents\Radio Daze\Times\Hours\';
const TimeMinutes : String = 'C:\Documents and Settings\Robert\My Documents\Radio Daze\Times\Minutes\';
const MyGMTZone   : Integer = +10;

var C,N          : Integer;
var fname        : String;
var fnamehh      : String;
var fnamemm      : String;
var ampm         : String;
var E : DateTime = Queue.ETA;    // Return the length of the queues
var hh,mm,ss,ms : Integer;

N := 0;
while N < 24 do begin



   DecodeTime(Now,hh,mm,ss,ms);
   if (hh = 0) then hh := 24;
   WriteLn('The Time Is '+IntToStr(hh)+':'+IntToStr(mm));

   //WriteLn('Wait for 10 Minutes');     // Say time every ten minutes
   //PAL.WaitForTime(T['+00:10:00']);

   //PAL.WaitForPlayCount(1);
   //DecodeTime(Now,hh,mm,ss,ms);
   
   E := Queue.ETA;                   // You could even wait for the current
     DecodeTime(E,hh,mm,ss,ms);        // cue length of time to finish
          if (hh <= 9) then
       fnamehh := '0'+IntToStr(hh)+'.mp3'       //get the right file name
     else
       fnamehh := IntToStr(hh)+'.mp3';         //get the right file name
         WriteLn(fnamehh);

    if (mm <= 9) then
       fnamemm := '0'+IntToStr(mm)+'.mp3'      //get the right file name
     else
       fnamemm := IntToStr(mm)+'.mp3';        //get the right file name
         WriteLn(fnamemm);

       fname := 'Header.mp3';
       
   WriteLn('SayTime at '+IntToStr(hh)+':'+IntToStr(mm));        // Just checking
   //PAL.WaitForTime(E);

   // you need to reverse the order, mm - hh - header, so that the header
 // ends up in queuetop.
 //Queue.AddFile(TimeMinutes+fnamemm,ipTop);
 //Queue.AddFile(TimeHours+fnamehh,ipTop);
 //Queue.AddFile(TimeHeader,ipTop);
 //ActivePlayer.FadeToNext;         // then fade to say the time.
 
 Queue.AddFile(TimeHeader+fname,ipBottom);
 Queue.AddFile(TimeHours+fnamehh,ipBottom);
 Queue.AddFile(TimeMinutes+fnamemm,ipBottom);
 PAL.WaitForTime(E);
 PAL.WaitForTime(T['+00:01:00']);
 PAL.WaitForQueue(5);            // wait till the queue fills again
                                  // but what does it do in the even that
                                  // there are more than 4 files already ??
                                  

 N := N+1;
end;

function ActivePlayer:TPlayer; 
begin 
if DeckA.Status = psPlaying then 
Result := DeckA 
else 
Result := DeckB; 
end;