Now playing via CURL command

For all that are interested… here’s the working Script (some functions dissabled though)

const
  iMax = 5;                                        
  IP = '10.0.0.151';                          
  PORT = '3310';                                  
  PATH = 'C:\sfk174.exe'; 
  
var
  sl: TStringList;
  pi: IPlaylistItem;
  idx, c, i: integer;
  EncoderState: array[0 .. iMax] of integer;  


procedure PostOnAirScreen(Command: string);
begin
  ShellExecuteHidden (PATH, 'udpsend ' + IP + Chr(32) + PORT + Chr(32) + Chr(34) + Command + Chr(34) + Chr(32) + '-quiet');
  end;

procedure OnLoad;
begin
  
//  PostOnAirScreen('CONF:LED2:autoflash=True'); 
//  PostOnAirScreen('CONF:LED2:text=EOF'); 

//  PostOnAirScreen('CONF:CONF:APPLY=TRUE'); 
//  PostOnAirScreen('LED1:OFF');
//  PostOnAirScreen('LED2:OFF');
//  PostOnAirScreen('LED3:OFF');
//  PostOnAirScreen('LED4:OFF');
PostOnAirScreen('AIR4:ON');
 // PostOnAirScreen('AIR4:RESET');
  
end;

procedure OnRuntimeDataChange(Key, Value: string);
begin
  if Key = 'EncoderStatus' then begin
    if Value = ('false') then begin
	  PostOnAirScreen('AIR4:OFF');
      PostOnAirScreen('AIR4:RESET');
	  end
	else begin
	  PostOnAirScreen('AIR4:ON');
	  end;
	end
  else if Key = 'GamepadStatus' then begin
    PostOnAirScreen(Value);
	end
  else if Key = 'EncoderError' then begin
    PostOnAirScreen(Value);
	end;
end;

function Escape(Oldstring: string): string;
var
  Newstring, Part: string;
  i: integer;
begin
  Newstring := '';
  for i := 1 to Length(Oldstring) do
    begin
      Part := Copy(Oldstring, i, 1);
      if Part = 'ä' then
        Part := 'a'
      else if (Part = 'ö') OR (Part = 'ø') OR (Part = 'œ') then
        Part := 'o' 
      else if Part = 'ü' then
        Part := 'u' 
      else if Part = 'å' then
        Part := 'a'             
      else if Part = 'é' then
        Part := 'e' 
      else if Part = 'ë' then
        Part := 'e' 		
      else if Part = 'Ä' then
        Part := 'A'      
      else if (Part = 'Ö') OR (Part = 'Ø') OR (Part = 'Œ') then
        Part := 'O'     
      else if Part = 'ï' then
        Part := 'i'   
	  else if Part = 'Ü' then
        Part := 'U'      
      else if Part = 'Å' then
        Part := 'A'      
      else if Part = 'ß' then
        Part := 'S'  
      else if Part = 'ñ' then
        Part := 'n' 
      else if Part = 'Ñ' then
        Part := 'N'; 
      Newstring := Newstring + Part;
    end;
  Result := Newstring;
end;

procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);

begin
if (Item.GetItemType = pitMusic) OR
//      (Item.GetItemType = pitDummy) OR
       (Item.GetItemType = pitNews) then 
  idx := CurrentPlaylist.IndexOf(item);
  if idx = -1 then begin
    PostOnAirScreen ('WARN:PLAYLIST IS LEEG!!');
//	SystemLog('Niets in de Playlist ...');
    exit;
  end;
  
  sl := TStringList.Create;
  c := 0;                                                                                                       
  while (idx < CurrentPlaylist.GetCount) and (c < 1) do begin
    pi := CurrentPlaylist.GetItem(idx);
	
    sl.Add(Escape(pi.GetArtist) + Chr(32) + '-' + Chr(32) + Escape(pi.GetTitle));
    c := c + 1;
    idx := idx + 1;
  end;
  if (Item.GetItemType = pitMusic) OR
//    (Item.GetItemType = pitDummy) OR
     (Item.GetItemType = pitNews) then 
  PostOnAirScreen('AIR4:RESET');	
  PostOnAirScreen('NOW:' + sl[0]);
 sl.Free;
end;

// procedure OnOnAir;
// begin
// PostOnAirScreen('LED1:ON');
// end;

// procedure OnOffAir;
// begin
// PostOnAirScreen('LED1:OFF');
// end;

procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer);
begin
  PostOnAirScreen('LED2:ON');
end;

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
  PostOnAirScreen('LED2:OFF');
end;


begin
end.

Me, answering.  

1 Like

Well I am really thankfull for your help on this!

1 Like

Why not use HTTP GET logging config from the GUI?

Torben, do elaborate please.
How will that work?

Config -> Logging -> Add -> HTTP GET