Timed auto close

Hello,

I search how to whrite a script to unload a playlist player on stop if it was played more than 5 secondes, else , the player have to stay loaded.

procedure OnPlayerStop(PlaylistIndex: integer; PlayerIndex: integer; Duration: TTimeValue; Item: IPlaylistItem);


begin
if (Duration > 50000000) then begin

  SystemLog('Stoped at : '+IntToStr(trunc(TimeValueToSeconds(Duration)))+'');

  ?????????????? unload player 1-X ??????????????

end;
end;

begin
end.

Thanks, Paul :wink:

Playlist(PlaylistIndex).GetPlayer(PlayerIndex).Close;

Regarding the time comparison, I recommend to write “Duration > SecondsToTimeValue(5)” so your script will continue to work when the internal time format will change from (large) integer to float in a future version.

thank you for the advice. ;D