You might have a shot at ShellExecuteHidden, if convenient.
(Please make sure that code gets the appropriate format on posting as the clever forum software is handling the apostrophes in its very own way. And else.)
Got only one issue…
I only want to display the Tags of Dummy, Music and News
This is disabled in my normal Textfile Logging…
Is this possible?
const
iMax = 5; // Hier die maximale Senderanzahl einsetzen
IP = '192.168.51.103'; // <-- IP-Adresse
PORT = '3310'; // <-- Port
PATH = 'C:\ProgramData\mAirList\6.1\sfk174.exe'; // <-- Pfad
var
sl: TStringList;
pi: IPlaylistItem;
idx, c, i: integer;
EncoderState: array[0 .. iMax] of integer;
procedure PostOnAirScreen(Befehl: string);
begin
ShellExecuteHidden (PATH, 'udpsend ' + IP + Chr(32) + PORT + Chr(32) + Chr(34) + Befehl + Chr(34) + Chr(32) + '-quiet');
//ShellExecute (PATH, 'udpsend ' + IP + Chr(32) + PORT + Chr(32) + Chr(34) + Befehl + Chr(34));
end;
procedure OnLoad;
begin
// Eigentlich muss das nicht mal bei jedem Ladevorgang neu passieren aber so sind wir sicher, dass da keiner was verfummelt hat
// und man kann relativ komfortabel die Konfiguration anpassen ohne dass man an die eigentliche Anzeige ran muss
PostOnAirScreen('CONF:LED2:autoflash=True'); // Diese Anzeige soll blinken, blinkede Anzeigen sehen immer wichtig aus.
PostOnAirScreen('CONF:LED2:text=EOF'); // Auf dem Button soll EOF stehen.
PostOnAirScreen('CONF:CONF:APPLY=TRUE');
PostOnAirScreen('LED1:OFF');
PostOnAirScreen('LED2:OFF');
PostOnAirScreen('LED3:OFF');
PostOnAirScreen('LED4:OFF');
PostOnAirScreen('AIR4:OFF');
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;
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Das war kein Element aus unserer Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) do begin
pi := CurrentPlaylist.GetItem(idx);
sl.Add(pi.GetArtist + Chr(32) + '-' + Chr(32) + pi.GetTitle );
c := c + 1;
idx := idx + 1;
end;
PostOnAirScreen('NOW:' + sl[0] );
PostOnAirScreen('NEXT:' + sl[1] );
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 OnPlayerStop(PlaylistIndex: integer; PlayerIndex: integer; Duration: TTimeValue; Item: IPlaylistItem);
procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
PostOnAirScreen('LED2:OFF');
end;
procedure OnShutdown; // Sollte den Rechner mit den OnAirScreen herunterfahren, funktioniert bisher aber nicht.
begin
PostOnAirScreen('CMD:SHUTDOWN');
end;
begin
end.
EDIT by Mod: formatted to code. Please use </> on marked up text.
Thank you.
Now using the code below, it is putting the Artist and Title, however when Artist is: Blue Öyster Cult it won’t (goes for all with special characters)
Any thoughts?
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Niets in de Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) do begin
pi := CurrentPlaylist.GetItem(idx);
sl.Add(pi.GetArtist + Chr(32) + '-' + Chr(32) + pi.GetTitle );
c := c + 1;
idx := idx + 1;
end;
if (Item.GetItemType = pitMusic) OR
(Item.GetItemType = pitDummy) OR
(Item.GetItemType = pitNews) then
PostOnAirScreen('NOW:' + sl[0] );
sl.Free;
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 := 'ae'
else if (Part = 'ö') OR (Part = 'ø') OR (Part = 'œ') then
Part := 'oe'
else if Part = 'ü' then
Part := 'ue'
else if Part = 'å' then
Part := 'aa'
else if Part = 'Ä' then
Part := 'Ae'
else if (Part = 'Ö') OR (Part = 'Ø') OR (Part = 'Œ') then
Part := 'Oe'
else if Part = 'Ü' then
Part := 'Ue'
else if Part = 'Å' then
Part := 'aa'
else if Part = 'ß' then
Part := 'ss'
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
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Niets in de Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) 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('NOW:' + sl[0]);
sl.Free;
end;
Please post code completely, otherwise it is impossible to track errors.
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 := 'ae'
else if (Part = 'ö') OR (Part = 'ø') OR (Part = 'œ') then
Part := 'oe'
else if Part = 'ü' then
Part := 'ue'
else if Part = 'å' then
Part := 'aa'
else if Part = 'Ä' then
Part := 'Ae'
else if (Part = 'Ö') OR (Part = 'Ø') OR (Part = 'Œ') then
Part := 'Oe'
else if Part = 'Ü' then
Part := 'Ue'
else if Part = 'Å' then
Part := 'aa'
else if Part = 'ß' then
Part := 'ss'
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
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Niets in de Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) 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.
Initially you asked for some method to send strings via curl, which you got meanwhile. Later on you came up with some complicated code using a very different programme (sfk174.exe). Debugging the latter (most of which you probably do not need anyway) ist taking too much time, so may I ask you to try it with the lightweight version first, please?
The complete code should look like this:
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 := 'ae'
else if (Part = 'ö') OR (Part = 'ø') OR (Part = 'œ') then
Part := 'oe'
else if Part = 'ü' then
Part := 'ue'
else if Part = 'å' then
Part := 'aa'
else if Part = 'Ä' then
Part := 'Ae'
else if (Part = 'Ö') OR (Part = 'Ø') OR (Part = 'Œ') then
Part := 'Oe'
else if Part = 'Ü' then
Part := 'Ue'
else if Part = 'Å' then
Part := 'aa'
else if Part = 'ß' then
Part := 'ss'
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
ShellExecuteHidden('curl', 'http://127.0.0.1:8010/?cmd=NOW: '
+ Escape(Item.GetArtist) + ' - ' + Escape(Item.GetTitle));
end;
begin
end.
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.