Adding items to playlist “just-in-time” / “infinite scroll”

Hi,

I’m writing a plugin for a source (of audio files) that is effectively infinite. I don’t want to try and populate the whole playlist, but rather I’d like to populate a bit – and when the end of the playlist is reached, automatically populate it with a bit more.

In fact an upcoming “playlist” is more of a nice to have really – I’d settle for simply control of the play/next/stop buttons.

So for example user starts my plugin playing, reaches end of file – kodi player asks my plugin for the next file and so on. Or if user presses the “next” button, kodi asks my plugin for the next file also.

Is this possible to achieve? I’ve experimented with subclassing the xbmc.Player and hooking into onPlayBackStarted/onPlayBackEnded as well as play/playnext but I can’t seem to achieve what I want. Are there any examples of plugins that do this already?

Cheers,
Eddie