0

I'm using the omxplayer-wrapper to run video files from python script. How can I run files according to the pressed buttons?
Example:
I want play file "a.mp4" until Button1 was pressed.
After Button1 pressed, I need to play file "b.mp4" and when it finished to play, I need to run the file "a.mp4" until Button2 was pressed.
After Button2 pressed, I need to play file "c.mp4" and when it finished to play, I need to run the file "a.mp4".

When I'm doing something similar to pseudo code example (below), I get the right behavior but I see the desktop for 1 second between the b.mp4 and a.mp4 files (after b was finished) and between c and a (after c was finished) it's 10-12 seconds.
What the proper way to do it?
Thanks a lot!!

Example pseudo code:

from omxplayer import OMXPlayer
from time import sleep

playerA = OMXPlayer('path/to/a.mp4', args=['-b', '--loop'])
playerB = OMXPlayer('path/to/b.mp4', args=['-b'])
playerC = OMXPlayer('path/to/c.mp4', args=['-b'])

playerA.play()

while True:
    if Button1PressedFlag==True: #set in interrupt
        Button1PressedFlag=False
        playerA.pause()
        playerB.play()
        while playerB.is_playing():
            sleep(0.2)
        playerB.quit()
        playerA.play()
    if Button2PressedFlag==True: #set in interrupt
        Button2PressedFlag=False
        playerA.pause()
        playerC.play()
        while playerC.is_playing():
            sleep(0.2)
        playerC.quit()
        playerA.play()
  • Try running your code without any of the sleep commands. – Mohammad Ali May 22 '16 at 15:06
  • The same behavior... – Michael May 23 '16 at 6:11
  • Your going to need to share a video of what's happening or write down what's happening in a step by step list format – Mohammad Ali May 23 '16 at 13:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.