turingmachine / omxplayer-sync

OMXPlayer-Sync facilitates synchronization of multiple OMXPlayer instances over the network in a master/slave fashion.
196 stars 70 forks source link

GPIO interface #62

Closed chuco61 closed 6 years ago

chuco61 commented 6 years ago

where in the code can I add in some GPIO trigger controls and would the signal be sent to the other slave pi's or is more advanced coding needed to pass the gpio trigger through the slaves?

turingmachine commented 6 years ago

Well, it depends what you want those triggers to do. Only timecodes are sent over the network, you would need to send gpio triggers separately.

chuco61 commented 6 years ago

Would that be a seprate .py or would it be added to the script you have?

Essentially I want to convert the "P" on my keyboard to where if the user HOLDS P down, the video plays, if released the video pauses.

magdesign commented 6 years ago

Keybindings are disabled in omxplayer-sync. You can use dbuscontrols instead. If you pause the master, also the slaves will pause. Why would you want send a gpio command over the sync procedure, this makes no sense. What are you trying to achive?

chuco61 commented 6 years ago

I am working on an art installation where 6 screens and 6 pi's are synced to a single video. I have this working currently, but would love to add an interactive component. That being, if a button is triggered (held down) then the video will play. If released or disengaged by the user, the video pauses until someone else re-engages the trigger. Im not quite sure how the dbuscontrols would be triggered using a keyboard to the master Pi.

chuco61 commented 6 years ago

I read another thread and it states that pause only works for about 4 seconds to allow syncing. So this option might not work. is it possible to switch between videos? No trigger call up videoA, trigger button on HOLD, call up videoB, revert to videoA on release.

magdesign commented 6 years ago

Of course you can switch videos, the video name played on master will be played on slave. You can write a simply python script which listens to Gpio and triggers the video. Pause works for 5 seconds, you can change the value in the omxplayer-sync script, its kind of a safety function, if for longer than 5 seconds no more timecode comes, it thinks that something hangs.

You could also run FBI in background with an image, if no omxplayer is running, it will display an image.

turingmachine commented 6 years ago

Some explanatory notes: If multiple videos are supplied to omxplayer-sync, all videos are played in succession. Currently it is not possible to switch to an arbitrary video or skip to the next. You could stop the omxplayer-sync on the master and restart with the video you want, the slaves will then immediately change to the correct video. Or you could just exit omxplayer via dbus, that way omxplayer-sync would play the next video in queue.

Also if you pause the omxplayer on master via dbus, the slaves would be stuck in a jump loop. So for pause to work correctly, you would need to send the command to omxplayer via dbus on the master and the slaves. Additionally you would need to remove the hangup_detection function, or you could raise the value that @magdesign mentioned. The value is located here https://github.com/turingmachine/omxplayer-sync/blob/master/omxplayer-sync#L328. But I would completely remove the call to hangup_detected if you want to introduce pause functionality.

There is a script in the omxplayer repository that sends dbus commands, that could be starting point: https://github.com/popcornmix/omxplayer/blob/master/dbuscontrol.sh

But you would still need to send those commands to the slaves as well. So you could create a program that listens to GPIO input, sends dbus commands to the local omxplayer instance and communicates with another program on the slaves that will receive those commands and send them to the local omplayer instance by dbus as well.

chuco61 commented 6 years ago

Thank you for this. I have one more idea, If I add chapter metadata to my video and use 'O' on my keyboard to skip chapters. Are the keyboard functions operational on omxplayer-sync, where I might be able to add an arduino keyboard via usb?

turingmachine commented 6 years ago

No, as @magdesign mentioned, omxplayer-sync does not capture keyboard strokes and does not forward them to omxplayer sync. But you could create a separate script that captures keystrokes from your arduino keyboard and sends commands to omxplayer via dbus.

chuco61 commented 6 years ago

Got it, thanks. This can be closed, Dbus comms is a far too advanced for me, although I will try and learn.