Assigning a (new) file to a playlist item (IPlaylistItem)

Hi,

I’m trying to understand how to attach a (new) file
to a playlist item.

In this example I sucessfully locate the playlist enty “HELLO WORD” in the CurrentPlaylist
and can change all kinds of things - but not assign a new file name to it?

Assuming I have the file “c:\mairlist\helloworld.mp3”, how can I assign this to the
found entry and then update the time information from the element?

I tried this approach, because I couldn’t find any way to assign a file to an existing playlist item.
The code runs and finds the entry, but doesn’t change it.

Any help?

[code]// MAirlist 4.3

var
i,j: integer;
st : string;
needle : string;

pi: IPlaylistItem;
pi_new: IPlaylistItem;

t1 : TDateTime;
t2 : TDateTime;

begin

SystemLog(‘Preparing hello world’);
pi_new:= Factory.CreateFilePlaylistItem(‘c:\mairlist\helloworld.mp3’,[]);

SystemLog(‘Looking for hello world’);

for i := 0 to CurrentPlaylist.GetCount - 1 do begin

pi := CurrentPlaylist.GetItem(i);
st := pi.GetTitle;

needle := 'HELLO WORLD';
j :=  pos(needle,st)
If j >0 then begin
  j := j + length(needle)  
    
    // Do something with pi.
   //  Exchange new element

    pi := pi_new;

    SystemLog('Found '+sr);
  end;  
end;

end;

end.
[/code]

UPDATE: I asked a similar question here https://www.mairlist.com/forum/index.php/topic,5673.0.html two years ago, after reading it again I’ll attempt to get that to work here,too. Basically the tip was to use “IPlaybackControl” instead of “IPlaylistItem” - so now I have to research how the exact syntax is to convert between the two. If I get it to work, I’ll post an update or the take question down.