next track logic

This commit is contained in:
KubaPro010
2025-11-07 20:33:26 +01:00
parent cdae200009
commit 4d021c373c
6 changed files with 40 additions and 175 deletions
+2 -3
View File
@@ -7,15 +7,14 @@ class Module(PlayerModule):
self.playlist = []
def on_new_playlist(self, playlist: list[Track]):
self.playlist = [str(t.path.absolute()) for t in playlist]
def on_new_track(self, index: int, track: Track):
def on_new_track(self, index: int, track: Track, next_track: Track | None):
if next_track: logger.info("Next up:", next_track.path.name)
if str(track.path) != self.playlist[index]:
# discrepancy, which means that the playing file was modified by the active modifier
# we are playing a file that was not determined in the playlist, that means it was chosen by the active modifier and made up on the fly
lines = self.playlist[:index] + [f"> ({track.path})"] + [self.playlist[index]] + self.playlist[index+1:]
logger.info("Next up:", Path(self.playlist[index]).name) # core no longer does this
else:
lines = self.playlist[:index] + [f"> {self.playlist[index]}"] + self.playlist[index+1:]
if index + 1 < len(self.playlist): logger.info("Next up:", Path(self.playlist[index+1]).name)
with open("/tmp/radioPlayer_playlist", "w") as f:
for line in lines:
try: f.write(line + "\n")