I have a simple project where I want to combine a motion sensor to play certain video files. So normally in an infinitive loop I want to play a flickering video and if the motion sensor is triggered I want to stop the flickering video and select a scary one. See the following code.
import RPi.GPIO as GPIO
import time
from omxplayer.player import OMXPlayer
from random import randint
#
def main():
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.IN)
flicks = ("/home/pi/halloween/flicks/tv_noise_1.mp4")
scares = ("/home/pi/halloween/scares/tv_noise_kitten_zombie_2.mp4")
omxc = OMXPlayer(flicks)
state = 0 # set initial state as 0
while True:
i = GPIO.input(17)
if(not omxc.is_playing()):
omxc = OMXPlayer(flicks)
if(state != i): # change in state detected
omxc.quit()
omxc = OMXPlayer(scares)
time.sleep(35) # wait as long as this video lasts
state = i
if __name__ == '__main__':
main()
However, I keep getting the error:
Traceback (most recent call last):
File "scare_old.py", line 29, in <module>
main()
File "scare_old.py", line 20, in main
if(not omxc.is_playing()):
File "<decorator-gen-90>", line 2, in is_playing
File "/home/pi/.local/lib/python2.7/site-packages/omxplayer/player.py", line 48, in wrapped
raise OMXPlayerDeadError('Process is no longer alive, can\'t run command')
omxplayer.player.OMXPlayerDeadError: Process is no longer alive, can't run command
What exactly is the problem? I mean the process should run because I'm just starting it before?