Hello,
I would like to insert a dummy item with metadata from another computer connected to the network. I use REST to execute this command:
POST /execute
command=InsertDummyPlaylistItem Jay-Z - Empire State Of Mind (feat. Alicia Keys)
procedure OnExecuteCommand(Command: string);
begin
if copy(Command, 1, 24) = 'InsertDummyPlaylistItem ' then begin
InsertDummyPlaylistItem(copy(Command, 25, 255));
end;
end;
[code]procedure InsertDummyPlaylistItem(Metadata: string);
var
dpi: IDummyPlaylistItem;
i: integer;
begin
for i := 1 to length(Metadata) do begin
if (Metadata[i] = ‘-’) then begin
// Create a dummy playlist item
dpi := Factory.CreateDummyPlaylistItem;
dpi.SetArtist(copy(Metadata, 0, i-2));
dpi.SetTitle(copy(Metadata, i+2, 255));
CurrentPlaylist.Insert(CurrentPlaylist.GetNextIndex, dpi);
exit;
end;
end;
end;[/code]
How can I more properly separate the artist and the title, with " - " as delimiter?
How can I read a json from an http call? My api looks like this : {“song”:{“artist”:“Jay-Z”,“title”:“Empire State Of Mind (feat. Alicia Keys)”}}
I would like to add the text on a button, like this: api := HTTPGet('APIURL');
ExecuteCommand('ARTIST TEXT ' + api.song.artist);
Thanks.