Script question

Hi Torben

Can you please advise what commands should be used in the following script to obtain the track duration and time of the fadeout point please?

var
	iMax, iItemCount, i : integer;
	currentItem: IPlaylistItem;
	slTextItems : TStringList;
	
begin
	iItemCount := CurrentPlaylist.GetCount;
	if iItemCount < 1 then
		SystemLog('Add items to playlist.')
	else
	begin
		SystemLog('Processing Playlist for text file export ('+ IntToStr(iItemCount)+ ' items).');
		slTextItems := TStringList.Create;
		iMax := iItemCount - 1;
		for i := 0 to iMax do
		begin
		  currentItem := CurrentPlaylist.GetItem(i);
		  slTextItems.add('TRACK ' + IntToStr(i)
// 		  + ' : "' + currentItem.GetDuration + '"'  //  < Duraton of current track??????
// 		  + ' : "' + currentItem.GetFadeOut + '"'  //  < Fade timen of current track??????
		  + ' : "' + currentItem.GetTitle + '"'
		  + ' - "' + currentItem.GetArtist + '"');
		end;
		slTextItems.SaveToFile('D:\PLitems.txt');
		slTextItems.Free;
     end;   
end.

Also – what command needs to be used to alter the fadeout point to a new value?

Thanks

Ron

Sorry - supplementary question.

How can I change the above script from using the playlist to using a database playlist which has already been generated (say the one for tomorrow at 14:00?) and then re-save it

Thanks again

Ron.

  1. Converting TimeValue (= number of seconds, floating point) to string: Actually depends on the desired output format, can you elaborate on this?

  2. Setting FadeOut:

currentItem.SetCuePosition(ptFadeOut, 123.456); // 00:02:03.456 
  1. Editing database playlist for a particular hour:
var
  pl: IPlaylist;

begin
  // Load playlist from DB:
  pl := Database(0).GetPlaylist(EncodeDate(2016, 3, 13) + EncodeTime(13, 0, 0, 0), 0);

  // do some work...

  // then save it back to DB:
  IDBConnection(Database(0)).SavePlaylist(EncodeDate(2016, 3, 13) + EncodeTime(13, 0, 0, 0), 0, pl);
end.

Saving only works for mAirListDB, thus the IDBConnection typecast. The extra “0” parameter is the sub-playlist number (0 = master playlist).

Hi Torben

Thanks for the quick reply.

I actually need to calculate the playlist duration (as seconds) so am trying to get this by adding the calculated start time of the final item and the effective duration of final item

I can do the first part by this code

iCurrentTotalSeconds :=  TimeToSeconds(Playlist(0).GetMetadata(iMax).GetStartTime(sttCalculated))     ////////////  + (Duration);

but I need to add the duration of the final item.

I then need to incorporate that value in the original text file.

Ron

Try this:

IntToStr(trunc(currentItem.GetDuration))

Not quite sure if the trunc function is included in all versions of mAirList - just give it a try.

It is and it works.

Thanks again Torben