Save all current changes: video profile, player fixes, and compatibility improvements

This commit is contained in:
2025-08-25 21:48:58 +03:00
parent f77f717af9
commit f4c73b54f7
12 changed files with 136 additions and 23 deletions

View File

@@ -3,6 +3,8 @@ import json
import tkinter as tk
from PIL import Image, ImageTk
import vlc
import subprocess
import sys
CONFIG_PATH = os.path.join(os.path.dirname(__file__), 'main_data', 'app_config.txt')
PLAYLIST_DIR = os.path.join(os.path.dirname(__file__), 'static_data', 'playlist')
@@ -158,7 +160,7 @@ class SimpleTkPlayer:
self.video_canvas.pack(fill=tk.BOTH, expand=True)
self.root.attributes('-fullscreen', True)
self.root.update_idletasks()
self.vlc_instance = vlc.Instance()
self.vlc_instance = vlc.Instance('--vout=x11')
self.vlc_player = self.vlc_instance.media_player_new()
self.vlc_player.set_mrl(file_path)
self.vlc_player.set_fullscreen(True)
@@ -236,16 +238,39 @@ class SimpleTkPlayer:
if self.paused is not True:
self.paused = True
self.pause_btn.config(text='▶ Resume')
import subprocess, sys
# Explicitly pause VLC video if playing
if hasattr(self, 'vlc_player') and self.vlc_player:
try:
self.vlc_player.pause()
except Exception:
pass
# Destroy controls overlay so settings window is always interactive
if hasattr(self, 'controls_win') and self.controls_win:
self.controls_win.destroy()
self.controls_win = None
settings_path = os.path.join(os.path.dirname(__file__), 'appsettings.py')
# Open settings in a new process so it doesn't block the main player
proc = subprocess.Popen([sys.executable, settings_path])
proc = subprocess.Popen([sys.executable, settings_path], close_fds=True)
# Give the window manager a moment to focus the new window
self.root.after(300, lambda: self.root.focus_force())
# Wait for the settings window to close, then resume
self.root.after(1000, lambda: self.check_settings_closed(proc))
def check_settings_closed(self, proc):
if proc.poll() is not None:
# Resume playback and unpause VLC if needed
self.resume_play()
# Restore and recreate controls overlay
self.root.deiconify()
self.create_controls()
self.show_controls()
if hasattr(self, 'vlc_player') and self.vlc_player:
try:
# Only resume if it was paused by us
if self.vlc_player.get_state() == vlc.State.Paused:
self.vlc_player.play()
except Exception:
pass
else:
self.root.after(1000, lambda: self.check_settings_closed(proc))