Play Video with gpio buttons
#1
Hello everyone, I'm working on a project with rasberry.
The project consists in a video loop, and then create 4 buttons using gpio.
When one of the four buttons is pressed, must start another video, this video has finished restart the initial loop.
Can someone help me?
Reply
#2
This thread might give you some pointers.

I've got my travelling Pi Zero media player wired up with 6 GPIO buttons which can be used to control Kodi. Details and scripting are in the thread above, but you'll have to modify the scripting to do specifically what you are looking for (mine are for general cursor direction controls plus select, then the 6th button is a "shift" button to give each of the other five a secondary action).
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#3
(2016-09-25, 14:29)DarrenHill Wrote: This thread might give you some pointers.

I've got my travelling Pi Zero media player wired up with 6 GPIO buttons which can be used to control Kodi. Details and scripting are in the thread above, but you'll have to modify the scripting to do specifically what you are looking for (mine are for general cursor direction controls plus select, then the 6th button is a "shift" button to give each of the other five a secondary action).

thanks DarrenHill, I saw the thread you linked to me, but I can not in any way to download the files you have uploaded to box, you can send them to me in another way?

How could I manage a video loop, then press a button to start another video, and at the end of this video back to the loop?
Reply
#4
The files are basically just the two that are reproduced in the thread itself, but set up as a service add-on. You should just need to click the link in that message to download that set-up and they will download. There is no simpler way to do it.

For the looping, that could possibly be done via a playlist (wiki) perhaps, with the GPIO button commands set up to jump around inside that playlist.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#5
when I try to download the "box" file does not make me to download, the link does not work.


(2016-09-25, 19:48)DarrenHill Wrote: The files are basically just the two that are reproduced in the thread itself, but set up as a service add-on. You should just need to click the link in that message to download that set-up and they will download. There is no simpler way to do it.

For the looping, that could possibly be done via a playlist (wiki) perhaps, with the GPIO button commands set up to jump around inside that playlist.
Reply
#6
Try this ==> click-me
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#7
(2016-09-26, 08:56)DarrenHill Wrote: Try this ==> click-me


Thanks, now it works, then I modified the file, okay?

Code:
#!/usr/bin/python

import sys
sys.path.append('/storage/.kodi/addons/python.RPi.GPIO/lib')

import RPi.GPIO as GPIO
import xbmc

upPin = 17        # board pin 11
downPin = 27    # board pin 13
leftPin = 22    # board pin 15
rightPin = 6    # board pin 31
selectPin = 13    # board pin 33
shiftPin = 19    # board pin 35

def up_callback(channel):
    if(GPIO.input(shiftPin)):
        xbmc.executebuiltin("Action(Up)")
    else:
        xbmc.executebuiltin("PlayMedia(/home/pi/video/video1.mp4)")

def down_callback(channel):
    if(GPIO.input(shiftPin)):
        xbmc.executebuiltin("Action(Down)")
    else:
        xbmc.executebuiltin("PlayMedia(/home/pi/video/video2.mp4)")
      
def left_callback(channel):
    if(GPIO.input(shiftPin)):
        xbmc.executebuiltin("Action(Left)")
    else:
        xbmc.executebuiltin("PlayMedia(/home/pi/video/video3.mp4)")

def right_callback(channel):
    if(GPIO.input(shiftPin)):
        xbmc.executebuiltin("Action(Right)")
    else:
        xbmc.executebuiltin("PlayMedia(/home/pi/video/video4.mp4)")

def select_callback(channel):
    if(GPIO.input(shiftPin)):
        xbmc.executebuiltin("Action(Select)")
    else:
        xbmc.executebuiltin("Action(ContextMenu)")

class Main:
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(upPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(downPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(leftPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(rightPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(selectPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(shiftPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.add_event_detect(upPin, GPIO.FALLING, callback=up_callback, bouncetime=300)
    GPIO.add_event_detect(downPin, GPIO.FALLING, callback=down_callback, bouncetime=300)
    GPIO.add_event_detect(leftPin, GPIO.FALLING, callback=left_callback, bouncetime=300)
    GPIO.add_event_detect(rightPin, GPIO.FALLING, callback=right_callback, bouncetime=300)
    GPIO.add_event_detect(selectPin, GPIO.FALLING, callback=select_callback, bouncetime=300)

    while not xbmc.abortRequested:
        xbmc.sleep(5)
        
class TidyUp:
    GPIO.remove_event_detect(upPin)
    GPIO.remove_event_detect(downPin)
    GPIO.remove_event_detect(leftPin)
    GPIO.remove_event_detect(rightPin)
    GPIO.remove_event_detect(selectPin)
    GPIO.cleanup([upPin,downPin,leftPin,rightPin,selectPin,shiftPin])

    
if (__name__ == "__main__"):
    Main()
    TidyUp()
[/php]





I would put a still image, and when for example you press one of the keys associated with the video, the video is played, the video ends, and returns you see that image fixed.
Can you help me?
Reply
#8
Help yourself to the file and modify it how you wish. That was why I made it available Smile Note you may need to also change the pin assignment numbers, depending on exactly which GPIO pin you have each button physically wired up to. My hardware board uses board pin numbers 11, 13, 15, 31, 33 and 35, but yours may be different. You can see where the assignment is made anyway, it's quite simple.

Your last request would probably require a special custom skin to be created, which is beyond my knowledge of how to do.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply

Logout Mark Read Team Forum Stats Members Help
Play Video with gpio buttons0