Video from GPIO Button presses programing help

I am trying to make a python program that uses GPIO buttons to play videos on a raspberry pi.

I do not really understand python and I need some help with the code to make the videos play.

I have tried to adapt the code from this source Play Video With Python and GPIO : 5 Steps (with Pictures) - Instructables to accept more button inputs.

The code I have used is:

import RPi.GPIO as GPIO

import os

import sys

from subprocess import Popen

GPIO.setmode(GPIO.BCM)

GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(8, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(2, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)

hint1 = ("/home/pi/Videos/P1H1.mp4")

repeats 2-12

last_state1 = True

repeats 2-12

input_state1 = True

repeats 2-12

player = False

While True:

input_state1 = GPIO.input(8)

repeats 1-12

if input_state1 != last_state1:

    if (player and not input_state1):

        os.system('killall omxplayer.bin')

        omxc = Popen(['omxplayer', '-b', hint1])

        player = True

    elif not input_state1:

        omxc = Popen(['omxplayer', '-b', hint1])

        player = True

repeats 2-12 but if is instead elif

elif (player and input_state1 and input_state2 repeats 3-12

    os.system('killall omxplayer.bin')

    player = False

last_state1 = input_state1

repeats 2-12

To save time and space I have used repeats. To save any confusion, repeats is the same as above but with the numbers changed to the repeats.

The results of this vary by button. Some play the indicated video, some will play the video when the button is held down, and most do nothing.

What I am trying to accomplish overall is to have 24 buttons that each play their own videos when pressed but not held in. Ideally, the videos will loop once the video finishes, and pressing another button switches to that video.

Thank you