jehutting / omxplayer-player

A player controlling omxplayer by gpio.
8 stars 3 forks source link

GPIO functionality only working if script started from shell, not at startup #2

Closed mazlmazl closed 6 years ago

mazlmazl commented 6 years ago

The GPIO functionality is only given if the script is startet from shell with a logged in user. If I try to start the script at reboot with rc.local, init.d oder crontab (as sudo or normal user), the player starts but there is no GPIO functionality. No errors are thrown. Maybe a user rights or runlevel issue? Is this issue reproducible and are there any solutions?

jehutting commented 6 years ago

The problem is caused by the keyboard functionality.

Try to replace the code in class Player function run

            # KEYBOARD control
            kb = KBHit()
            while True:
                if kb.kbhit():
                    c = kb.getch()
                    #print(c)
                    if c == chr(27): # ESC key to quit
                        self.log('ESC key pressed')
                        break
                    elif c == 'q': # <== and this one too to quit
                        self.log('Quit key pressed')
                        break
                    elif c == ' ': # <== SPACE key for Play/Pause
                        self.log('SPACE key pressed')
                        self.__onPlayButtonChanged(1)
                    elif c == 'p': # <== PREVIOUS key
                        self.log('PREVIOUS key pressed')
                        self.__onPreviousButtonChanged(1)
                    elif c == 'n': # <== NEXT key
                        self.log('NEXT key pressed')
                        self.__onNextButtonChanged(1)               
                time.sleep(1)

by

            while True:

                time.sleep(1)

I do not know why the keyboard functionality kills the GPIO working. Probably it has something to do with the process not having a stdin stream.

mazlmazl commented 6 years ago

That´s it. Thanks a lot.