2023-05-22, 03:40
I have an addon which has a service that monitors playback using the xbmc.player class with the onPlayBackEnded, etc. methods to monitor what the Kodi player is doing. I have another part of the addon which dynamically creates a playlist and plays it. Everything works fine but I am trying to, in the service part of the addon, to detect when the playlist has completed playback. Kodi doesn't have an xbmc.player method like onPlayListEnded or similar so when the playlist is playing I get onPlayBackEnded followed by onPlayBackStarted.
I am trying to find a simple but reliable solution to determine when the playlist has ended vs. a normal file. Note that the addon also plays many single files vs. the dynamic playlists. One solution I thought of is when the dynamic playlist is crated and starts playing, set an addon setting variable with the number of items in the playlist +1 . Then when onPlayBackEnded is reached, decrement the addon setting variable by 1 and when the addon setting variable value reaches 1 when onPlayBackEnded I'll know it just played the last item in the playlist. Then I do something and set the value to 0.
This should work but it isn't elegant and I am sure there is likely a better option. I was thinking possibly of an JSON RPC call to check the position in the playlist onPlayBackEnded but when playback ends after the last item, the playlist is destroyed.
Open to suggestions. I would think detecting the end of a playlist vs. the end of an individual file playback is something others have needed in other addons vs.this being something really unique.
Thanks in advance,
Jeff
I am trying to find a simple but reliable solution to determine when the playlist has ended vs. a normal file. Note that the addon also plays many single files vs. the dynamic playlists. One solution I thought of is when the dynamic playlist is crated and starts playing, set an addon setting variable with the number of items in the playlist +1 . Then when onPlayBackEnded is reached, decrement the addon setting variable by 1 and when the addon setting variable value reaches 1 when onPlayBackEnded I'll know it just played the last item in the playlist. Then I do something and set the value to 0.
This should work but it isn't elegant and I am sure there is likely a better option. I was thinking possibly of an JSON RPC call to check the position in the playlist onPlayBackEnded but when playback ends after the last item, the playlist is destroyed.
Open to suggestions. I would think detecting the end of a playlist vs. the end of an individual file playback is something others have needed in other addons vs.this being something really unique.
Thanks in advance,
Jeff