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 automatically 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 automatically the file "a.mp4".
When I'm doing something similar to pseudo code example (below), I get error that dbus cannot connect to omxplayer process.
So, I think I do it wrong. What the proper way to do it?
Thanks a lot!!
Example pseudo code:
Code: Select all
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()