@@ -31,6 +31,7 @@ class VideoPlayerWidget(QWidget):
3131 request_hide_main_window = pyqtSignal ()
3232 request_show_main_window = pyqtSignal ()
3333 pause_changed = pyqtSignal (bool )
34+ subtitle_style_changed = pyqtSignal (str , object )
3435
3536 def __init__ (self , parent = None ):
3637 super ().__init__ (parent )
@@ -44,6 +45,9 @@ def __init__(self, parent=None):
4445 self .is_loading = False
4546 self .auto_play_pending = False
4647 self .player = None
48+ self .sub_color = "#FFFFFF"
49+ self .sub_border_color = "#000000"
50+ self .sub_scale = 1.0
4751 self .setup_ui ()
4852 self .setup_mpv ()
4953
@@ -216,6 +220,10 @@ def setup_mpv(self):
216220 log_handler = print ,
217221 loglevel = 'warn'
218222 )
223+
224+ # Apply initial subtitle styles
225+ self ._apply_subtitle_styles ()
226+
219227 @self .player .property_observer ('time-pos' )
220228 def time_observer (_name , value ):
221229 if value is not None :
@@ -310,6 +318,7 @@ def load_video(self, file_path, saved_position=0, volume=100, auto_play=True):
310318
311319 self .player .sid = 'no'
312320 self .player .loadfile (file_path )
321+ self ._apply_subtitle_styles ()
313322 self .play_btn .setEnabled (True )
314323 self .progress_slider .setEnabled (True )
315324 self .frame_back_btn .setEnabled (True )
@@ -658,20 +667,61 @@ def change_subtitle_style(self, property_name, value):
658667 # Convert HEX to MPV format (ARGB)
659668 hex_color = value .lstrip ('#' )
660669 self .player .sub_color = f"#FF{ hex_color .upper ()} "
670+ self .sub_color = value
671+ self .subtitle_style_changed .emit ("sub-color" , value )
661672 print (f"📝 Subtitle color: { value } " )
662673 elif property_name == "sub-border-color" :
663674 hex_color = value .lstrip ('#' )
664675 self .player .sub_border_color = f"#FF{ hex_color .upper ()} "
676+ self .sub_border_color = value
677+ self .subtitle_style_changed .emit ("sub-border-color" , value )
665678 print (f"📝 Subtitle border color: { value } " )
666679 elif property_name == "sub-scale" :
667680 # value is delta (+5 or -5)
668681 current_scale = getattr (self .player , 'sub_scale' , 1.0 )
669682 new_scale = max (0.5 , min (3.0 , current_scale + value / 100.0 ))
670683 self .player .sub_scale = new_scale
684+ self .sub_scale = new_scale
685+ self .subtitle_style_changed .emit ("sub-scale" , new_scale )
671686 print (f"📝 Subtitle scale: { new_scale :.2f} " )
672687 except Exception as e :
673688 print (f"Error changing subtitle style: { e } " )
674689
690+ def set_subtitle_styles (self , color , border_color , scale ):
691+ """Set initial subtitle styles."""
692+ self .sub_color = color
693+ self .sub_border_color = border_color
694+ self .sub_scale = scale
695+
696+ # Also sync with popup
697+ if hasattr (self , 'subtitle_btn' ):
698+ self .subtitle_btn .popup .text_color = color
699+ self .subtitle_btn .popup .outline_color = border_color
700+ self .subtitle_btn .popup ._update_text_color_btn ()
701+ self .subtitle_btn .popup ._update_outline_color_btn ()
702+
703+ if self .player :
704+ self ._apply_subtitle_styles ()
705+
706+ def _apply_subtitle_styles (self ):
707+ """Apply stored subtitle styles to MPV player."""
708+ if not self .player :
709+ return
710+
711+ try :
712+ # Color
713+ hex_color = self .sub_color .lstrip ('#' )
714+ self .player .sub_color = f"#FF{ hex_color .upper ()} "
715+
716+ # Border
717+ hex_border = self .sub_border_color .lstrip ('#' )
718+ self .player .sub_border_color = f"#FF{ hex_border .upper ()} "
719+
720+ # Scale
721+ self .player .sub_scale = self .sub_scale
722+ except Exception as e :
723+ print (f"Error applying subtitle styles: { e } " )
724+
675725 def change_subtitle_track (self , index ):
676726 """Switch subtitles on selection."""
677727 if not self .player : return
0 commit comments