Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pause and seek at a moment? #8

Closed
Akascape opened this issue Jun 2, 2022 · 4 comments
Closed

How to pause and seek at a moment? #8

Akascape opened this issue Jun 2, 2022 · 4 comments

Comments

@Akascape
Copy link

Akascape commented Jun 2, 2022

I am a little bit confused on the seek method, when I seek to a part while the video is paused then it doesn't display the frame, means it only displays the seeked part when it is played.
I tried this method after seek while pausing the video and it worked but we have to use the time module and I think its not accurate;

vid_player.seek(int(5)) 
vid_player.play()
time.sleep(0.1)
vid_player.pause()

Any fix for this? I just want to display the video frame when seeked without playing it.

@PaulleDemon
Copy link
Owner

PaulleDemon commented Jun 2, 2022

Hello @Akascape, I wouldn't recommend using time.sleep as it can block the mainloop. I would suggest u use

def seek_pause(seek_sec=0):
    vid_player.seek(seek_sec)
    vid_player.play() 
    vid_player.pause()

seek_pause(5)

Let me know if this worked for u.

@Akascape
Copy link
Author

Akascape commented Jun 2, 2022

@PaulleDemon I tried this method but it was not working. Thats why I used the time method. Please let me know if this is happening in your system also.
The pause method just pauses the video while playing but don't seek to the frame.

@PaulleDemon
Copy link
Owner

PaulleDemon commented Jun 3, 2022

@Akascape Hmm sorry I hadn't tested that, my laptop is given for repair, I am using my phone.

I have updated the previous code if that doesn't work try the below

def seek(sec):
    vid_player.seek(sec)
    vid_player.after(5, vid_player.pause) # test this, the first parameter is time in milliseconds, u can change this according to ur need.

seek(20)    

@Akascape
Copy link
Author

Akascape commented Jun 3, 2022

@PaulleDemon The previous code didn't work but the next one worked, but we have to add another line:

def seek(sec):
    vid_player.seek(sec)
    vid_player.play() #have to play it so that it displays the seeked frame
    vid_player.after(50, vid_player.pause)
seek(20)  

@Akascape Akascape closed this as completed Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants