From bf25de9ce42c8c53e624cfd05af48420b1165709 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 24 Feb 2011 15:16:27 -0500 Subject: [PATCH] -fixed synchronization of song-start to ui-start after very long playback (greater than 48 hours) --- pypo/pypo-cli.py | 11 ++++++++--- pypo/scripts/ls_script.liq | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/pypo/pypo-cli.py b/pypo/pypo-cli.py index a2248c7e0..638ef6e6e 100755 --- a/pypo/pypo-cli.py +++ b/pypo/pypo-cli.py @@ -692,11 +692,16 @@ class Playout: # Get any extra information for liquidsoap (which will be sent back to us) liquidsoap_data = self.api_client.get_liquidsoap_data(pkey, schedule) - logger.debug("Sending additional data to liquidsoap: "+str(liquidsoap_data["schedule_id"])) + logger.debug("Sending additional telnet data to liquidsoap: "+str(liquidsoap_data["schedule_id"])) + + #skip the currently playing song if any. + logger.debug("source.skip\n") + tn.write("source.skip\n") - #Sending JSON string. Example: {"schedule_id":"13"} + #Sending schedule table row id string. + logger.debug("vars.pypo_data %s\n"%(str(liquidsoap_data["schedule_id"]))) tn.write("vars.pypo_data %s\n"%(str(liquidsoap_data["schedule_id"]))) - + for line in pl_file.readlines(): line = line.strip() logger.debug(line) diff --git a/pypo/scripts/ls_script.liq b/pypo/scripts/ls_script.liq index 5d7ae465c..e0b100866 100644 --- a/pypo/scripts/ls_script.liq +++ b/pypo/scripts/ls_script.liq @@ -22,6 +22,22 @@ def crossfade(s) cross(fader,s) end +# Add a skip function to a source +# when it does not have one +# by default +def add_skip_command(s) = + # A command to skip + def skip(_) = + source.skip(s) + "Done!" + end + # Register the command: + server.register(namespace="source", + usage="skip", + description="Skip the current song.", + "skip",skip) +end + server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end) default = single("/opt/pypo/files/basic/silence.mp3") @@ -32,6 +48,10 @@ s = fallback(track_sensitive=false, [queue, default]) s = on_metadata(notify, s) s = crossfade(s) +# Attach a skip command to the source s: +add_skip_command(s) + + if output_sound_device then out_device = out(s) end