@@ -209,6 +209,7 @@ def download_video_and_display_progress(
209209 gui .progress_bar ["value" ] = 0
210210 gui .progress_percent .set ("0%" )
211211 # Reset flags
212+ gui .pause_download = False
212213 gui .cancel_download = False
213214 gui .downloading = True
214215 # Ensure initial draw
@@ -228,10 +229,16 @@ def update_progress() -> None:
228229 # Reset progress bar, label and flags
229230 gui .progress_bar ["value" ] = 0
230231 gui .progress_percent .set ("0%" )
232+ gui .pause_download = False # reset pause flag
231233 gui .cancel_download = False # reset cancel flag
232234 gui .downloading = False
233235 logger .info ("Download cancelled by user." )
234236 return
237+ elif gui .pause_download :
238+ logger .info ("Download paused by user." )
239+ while gui .pause_download :
240+ time .sleep (0.1 ) # Wait until unpaused
241+ logger .info ("Download resumed by user." )
235242
236243 if not chunk :
237244 continue
@@ -310,6 +317,24 @@ def cancel_download(gui: VideoDownloaderUI) -> None:
310317 gui .log_message (gui .translations ["cancelled_message" ])
311318
312319
320+ def pause_resume_download (gui : VideoDownloaderUI ) -> None :
321+ """Sets the pause flag to True."""
322+ logger .debug ("Pause download button clicked" )
323+ if not gui .downloading :
324+ gui .log_message (gui .translations ["no_download_message" ])
325+ logger .warning ("No download in progress to pause/resume." )
326+ return
327+
328+ if gui .pause_download :
329+ gui .pause_download = False
330+ gui .log_message (gui .translations ["resumed_message" ])
331+ logger .info ("Download resumed by user." )
332+ else :
333+ gui .pause_download = True
334+ gui .log_message (gui .translations ["paused_message" ])
335+ logger .info ("Download paused by user." )
336+
337+
313338def change_language (gui : VideoDownloaderUI , lang_code : str ) -> None :
314339 if gui .current_language == lang_code :
315340 logger .debug ("Language change requested but already set to %s" , lang_code )
0 commit comments