feat: rate based sync

This commit is contained in:
Justin Lin
2025-10-09 16:42:35 +11:00
parent ca0a880c80
commit d335245eb0
8 changed files with 229 additions and 24 deletions

View File

@@ -30,7 +30,8 @@ def main():
def on_state_change(state):
print(f"Synchan update: playing={state.playing}, "
f"time={state.currentTime:.2f}s, "
f"duration={state.duration:.2f}s")
f"duration={state.duration:.2f}s, "
f"latency={state.latency:.0f}ms")
player.on_state_change = on_state_change
@@ -52,6 +53,8 @@ def main():
print("- Press 's' to stop")
print("- Press 'f' to toggle fullscreen")
print("- Press 'v' to change volume")
print("- Press 'r' to show current rate")
print("- Press 'l' to show latency info")
print("- Press 'q' to quit")
print("- Press 'j' to seek forward 10s")
print("- Press 'k' to seek backward 10s")
@@ -84,6 +87,12 @@ def main():
new_vol = min(100, current_vol + 10)
player.set_volume(new_vol)
print(f"Volume: {new_vol}")
elif key == 'r':
current_rate = player.get_rate()
print(f"Current playback rate: {current_rate:.3f}")
elif key == 'l':
pos = player.get_position()
print(f"Position: {pos:.2f}s")
elif key == 'j':
current_pos = player.get_position()
player.seek(current_pos + 10)