Stable: Fullscreen player, intro video, playlist update, overlay controls, clean shutdown, mouse hide, and robust exit fixes

This commit is contained in:
2025-08-25 15:30:37 +03:00
parent 027709618e
commit 1ea2ee584c
16 changed files with 626 additions and 46 deletions

View File

@@ -9,8 +9,8 @@ MEDIA_DATA_PATH = os.path.join(os.path.dirname(__file__), 'static_data', 'media'
PLAYLIST_DIR = os.path.join(os.path.dirname(__file__), 'static_data', 'playlist')
LOCAL_PLAYLIST_PATH = os.path.join(PLAYLIST_DIR, 'server_playlist.json')
def playlist_update_loop(refresh_time, stop_event, config, local_playlist_path, media_dir, playlist_dir):
while not stop_event.is_set():
def playlist_update_loop(refresh_time, app_running, config, local_playlist_path, media_dir, playlist_dir):
while app_running[0]:
updated = update_playlist_if_needed(local_playlist_path, config, media_dir, playlist_dir)
if updated:
print(f"[REFRESH] Playlist updated from server at {time.strftime('%X')}")
@@ -18,24 +18,54 @@ def playlist_update_loop(refresh_time, stop_event, config, local_playlist_path,
print(f"[REFRESH] Playlist already up to date at {time.strftime('%X')}")
time.sleep(refresh_time)
import tkinter as tk
from player import SimpleTkPlayer, load_latest_playlist
def main():
with open(CONFIG_PATH, 'r') as f:
config = json.load(f)
refresh_time = int(config.get('refresh_time', 5)) * 60 # minutes
stop_event = threading.Event()
app_running = [True]
update_thread = threading.Thread(
target=playlist_update_loop,
args=(refresh_time, stop_event, config, LOCAL_PLAYLIST_PATH, MEDIA_DATA_PATH, PLAYLIST_DIR),
args=(refresh_time, app_running, config, LOCAL_PLAYLIST_PATH, MEDIA_DATA_PATH, PLAYLIST_DIR),
daemon=True
)
update_thread.start()
print("Playlist update thread started. Press Ctrl+C to exit.")
root = tk.Tk()
root.title("Simple Tkinter Player")
root.configure(bg='black')
root.attributes('-fullscreen', True)
# Load playlist and create player
playlist = load_latest_playlist()
player = SimpleTkPlayer(root, playlist)
player.app_running = app_running
orig_exit_app = player.exit_app
def exit_and_stop():
app_running[0] = False
orig_exit_app()
player.exit_app = exit_and_stop
player.exit_btn.config(command=player.exit_app)
player.main_start()
def reload_playlist_if_updated():
new_playlist = load_latest_playlist()
if new_playlist != player.playlist:
player.playlist = new_playlist
player.current_index = 0
player.show_current_media()
root.after(10000, reload_playlist_if_updated)
reload_playlist_if_updated()
try:
while True:
time.sleep(1)
root.mainloop()
except KeyboardInterrupt:
print("Exiting...")
stop_event.set()
pass
finally:
app_running[0] = False
update_thread.join()
if __name__ == '__main__':