Following on from a previous thread about inserting a track to the current playlist using the database id provided by a php script using the following piece of mAirList script:
begin
CurrentPlaylist.Insert(CurrentPlaylist.GetNextIndex, Database(0).CreatePlaylistItem(HTTPGet('http://example.com/example.php')));
end.
is it possible to use a similar method for inserting multiple tracks if the php script spits out multiple IDs? mAirList script isn’t one of my strong points unfortunately so not sure how I would go about such a thing!
var
list: IStrings;
i: integer;
begin
list := Factory.CreateStrings;
list.SetText(HTTPGet('http://example.com/example.php'));
CurrentPlaylist.BeginUpdate;
try
for i := 0 to list.GetCount - 1 do
CurrentPlaylist.Insert(CurrentPlaylist.GetNextIndex + i, Database(0).CreatePlaylistItem(list.GetItem(i)));
finally
CurrentPlaylist.EndUpdate;
end;
end.
The BeginUpdate/EndUpdate locks the playlist during the insert process, so that GetNextIndex is not updated until we release it again.