Video player by Python tkinter, When I pause video, I cannot re-play

后端 未结 4 1015
时光说笑
时光说笑 2021-01-19 05:06

I am creating GUI to play video files. The problem is that when I pause video, Play button cannot re-play that video, and I have to select video file again.

Note: S

4条回答
  •  悲哀的现实
    2021-01-19 05:46

    Question: Pause button will have no effect.

    Reference:

    • Tkinter.Widget.after-method - after(delay_ms, callback=None, *args)

      Registers an callback that is called after a given time.

    • Tkinter.Widget.after_cancel-method - after_cancel(id)

      Cancels an callback.


    To cancel the allready queued events for self.play_video change the following:

    def play_video(self):
        ...
    
        if self.pause:
            self.window.after_cancel(self.after_id)
        else:
            self.after_id = self.window.after(self.delay, self.play_video)
    

提交回复
热议问题