aaaabbbb
This commit is contained in:
Binary file not shown.
@@ -16,6 +16,7 @@ from media_playback_controller import MediaPlaybackController
|
||||
from splash_screen import SplashScreen
|
||||
from playlist_manager import PlaylistManager
|
||||
from threading import Thread
|
||||
from settings_screen import SettingsWindow
|
||||
|
||||
if __name__ == "__main__":
|
||||
import tkinter as tk
|
||||
@@ -43,8 +44,23 @@ if __name__ == "__main__":
|
||||
playlist = playlist_manager.wait_for_playlist()
|
||||
Logger.info(f"[MAIN] Playlist loaded: {playlist}")
|
||||
Thread(target=preload_first_media, args=(playlist,), daemon=True).start()
|
||||
ui = PlayerUI(root)
|
||||
playback = MediaPlaybackController(app=None, ui=ui)
|
||||
# Create playback first so we can reference its methods in callbacks
|
||||
playback = MediaPlaybackController(app=None, ui=None) # UI will be set after
|
||||
def open_settings():
|
||||
SettingsWindow(root, None)
|
||||
def show_exit():
|
||||
root.quit()
|
||||
control_callbacks = {
|
||||
'prev': playback.previous_media,
|
||||
'play_pause': playback.toggle_play_pause,
|
||||
'next': playback.next_media,
|
||||
'settings': open_settings,
|
||||
'exit': show_exit
|
||||
}
|
||||
ui = PlayerUI(root, control_callbacks=control_callbacks)
|
||||
ui.setup_window() # Ensure fullscreen and geometry
|
||||
ui.bind_show_controls_on_activity() # Bind activity to show controls
|
||||
playback.ui = ui # Set UI reference now that it's created
|
||||
playback.set_playlist(playlist or [])
|
||||
playback.play_current_media()
|
||||
Logger.info("[MAIN] Player UI and playback started.")
|
||||
|
||||
@@ -14,6 +14,25 @@ class PlayerUI:
|
||||
self.exit_btn = None
|
||||
self.settings_btn = None
|
||||
self.hide_controls_timer = None
|
||||
# Set fullscreen and geometry before packing widgets
|
||||
self.root.title("Simple Signage Player")
|
||||
self.root.configure(bg='black')
|
||||
try:
|
||||
config = None
|
||||
try:
|
||||
from python_functions import load_config
|
||||
config = load_config()
|
||||
except Exception:
|
||||
pass
|
||||
width = int(config.get('screen_w', 1920)) if config else 1920
|
||||
height = int(config.get('screen_h', 1080)) if config else 1080
|
||||
self.scaling_mode = config.get('scaling_mode', 'fit') if config else 'fit'
|
||||
except:
|
||||
width, height = 1920, 1080
|
||||
self.scaling_mode = 'fit'
|
||||
self.root.geometry(f"{width}x{height}")
|
||||
self.root.attributes('-fullscreen', True)
|
||||
self.root.focus_set()
|
||||
self.setup_ui(control_callbacks)
|
||||
|
||||
def setup_ui(self, control_callbacks=None):
|
||||
@@ -160,3 +179,11 @@ class PlayerUI:
|
||||
y_offset = (screen_height - new_height) // 2
|
||||
final_img.paste(img_resized, (x_offset, y_offset))
|
||||
return final_img, (x_offset, y_offset)
|
||||
|
||||
def bind_show_controls_on_activity(self):
|
||||
def on_activity(event=None):
|
||||
self.show_controls()
|
||||
self.schedule_hide_controls()
|
||||
self.root.bind('<Button-1>', on_activity)
|
||||
self.root.bind('<Motion>', on_activity)
|
||||
self.root.bind('<Key>', on_activity)
|
||||
|
||||
Reference in New Issue
Block a user