liquidsoap icon indicating copy to clipboard operation
liquidsoap copied to clipboard

`on_track_end` callback

Open toots opened this issue 2 years ago • 8 comments

We really need a callback to be triggered when a source's track ends. It's a little tricky to define b/c of the streaming model, which is why I haven't added one for 2.0.0 but I definitely would like to add one for 2.1.0

toots avatar Oct 01 '21 13:10 toots

Hi, I would like to delete my media file once it has been streamed. I get in log: "Finished with " (and my file URI) which i see is generated by https://github.com/savonet/liquidsoap/blob/499befcaf6296b9f65fe74bd0f573db8c798dc83/src/sources/request_source.ml#L164 anyway i can do this ?

hayden-t avatar Feb 28 '22 07:02 hayden-t

Hi, I would like to delete my media file once it has been streamed. I get in log: "Finished with " (and my file URI) which i see is generated by

https://github.com/savonet/liquidsoap/blob/499befcaf6296b9f65fe74bd0f573db8c798dc83/src/sources/request_source.ml#L164

anyway i can do this ?

How do you queue your files? Files downloaded from remote URLs are always deleted after being played.

toots avatar Mar 21 '22 09:03 toots

Files (local) are queued via socket connection and push command Since posting this i worked out that i can prefix the file path with tmp: and then LS deletes them whon done. But still might be nice to have a call back at finished when.

hayden-t avatar Mar 21 '22 19:03 hayden-t

Yes, good catch on tmp:! I agree with you that this would be useful nonetheless.

toots avatar Mar 22 '22 09:03 toots

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 05:09 stale[bot]

Hello! Wondering if there's any updates on this? I would like to have LS do a HTTP request at the end of each track.

I'm currently doing it by having a callback on on_track, and calculate the previous track based on the playlist, but it only works well when the playlist mode is set to normal

Thanks :)

periode avatar May 07 '23 21:05 periode

Hi! I think the best for us would be to wait for the v2.3.x release cycle where we're planning to rewrite the streaming model. Meanwhile, Have you tried to look at source.on_end ? You should be able to trigger a callback very shortly before the end of a track.

toots avatar May 13 '23 12:05 toots

Sounds good! yes, for now I'm doing a workaround with source.on_end and it works well, albeit with some slightly unpleasant edge-case handling ;)

periode avatar May 13 '23 14:05 periode