1

I'm creating a program that plays a video when a GPIO button is pressed and once the selected video ends and closes I want to play a filler video while no button is pressed. To do this, I was wondering how one would check if a certain program is running programmatically?

import RPi.GPIO as gpio
import time, sys, os

gpio.setmode(gpio.BCM)
gpio.setup(23, gpio.IN)
gpio.setup(25, gpio.IN)

os.system('pkill omxplayer')
os.system('omxplayer -b Shopping.mp4 &')

while True:
    if gpio.input(23):
        os.system('pkill omxplayer')
        os.system('omxplayer -b Shopping.mp4 &')

    if gpio.input(25):
        os.system('pkill omxplayer')
        os.system('omxplayer -b Dodgeball.mp4 &')

    # if omxplayer is not running, then run the filler video
Bonifacio2
  • 3,405
  • 6
  • 34
  • 54
Malik Brahimi
  • 16,341
  • 7
  • 39
  • 70

0 Answers0