Start video on hdmi with node red

Hi all,
I want test something with node red and one raspberry pi.

I use HC SR04 (ultra sonic sensor). If my SR04 is under 10 i want play a video.

Si for this i use the node RPI-SRF and i made a little function.

if(msg.payload < 10){
    msg.payload = "PLAYVIDEO"
}
return msg;

after this node I put an exec mode with this command "mpg123 /home/pi/Desktop/flip2.mov"
But in debug node i've this msg.payload "".

So question, How to play a vidéo in fullscreen when the SR04 is under 10cm ?

[
    {
        "id": "e63e6f037fea2e7f",
        "type": "rpi-srf",
        "z": "0a43e3503ec04468",
        "name": "Capteur de proximité",
        "topic": "SRF",
        "pulse": "0.5",
        "pins": "35,37",
        "precision": "0",
        "x": 2990,
        "y": 1280,
        "wires": [
            [
                "72c228dd03b00f70"
            ]
        ]
    },
    {
        "id": "72c228dd03b00f70",
        "type": "function",
        "z": "0a43e3503ec04468",
        "name": "Sensibilité capteur",
        "func": "if(msg.payload < 10){\n    msg.payload = \"PLAYVIDEO\"\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 3300,
        "y": 1300,
        "wires": [
            [
                "f865e04384c37cf0",
                "579d56c98f95ef55"
            ]
        ]
    },
    {
        "id": "f865e04384c37cf0",
        "type": "exec",
        "z": "0a43e3503ec04468",
        "command": "mpg123 /home/pi/Desktop/flip2.mov",
        "addpay": "payload",
        "append": "VIDEO",
        "useSpawn": "false",
        "timer": "0",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 3670,
        "y": 1320,
        "wires": [
            [
                "05d9470753db434d"
            ],
            [],
            [
                "7a66713f34f14a28"
            ]
        ]
    },
    {
        "id": "05d9470753db434d",
        "type": "debug",
        "z": "0a43e3503ec04468",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 4140,
        "y": 1280,
        "wires": []
    },
    {
        "id": "7a66713f34f14a28",
        "type": "debug",
        "z": "0a43e3503ec04468",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 4070,
        "y": 1400,
        "wires": []
    },
    {
        "id": "579d56c98f95ef55",
        "type": "debug",
        "z": "0a43e3503ec04468",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 3540,
        "y": 1100,
        "wires": []
    }
]

thanks in advance

I think mpg123 just plays audio??

If Mpg123 just play audio, what can i use for this ?

I tried VLC but is not work too..

i've this on my debug node :

VLC media player 3.0.16 Vetinari
Command Line Interface initialized. Type `help' for help.
Command failed: vlc /home/pi/Desktop/flip2.mov 108 VIDEO
[014e7108] vlcpulse audio output error: PulseAudio server connection failure: Connexion refusée
[01525478] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[01525478] main interface error: no suitable interface module
[01461b98] main libvlc error: interface "dbus,none" initialization failed
[0150f930] main interface error: no suitable interface module
[01461b98] main libvlc error: interface "globalhotkeys,none" initialization failed
[01461b98] main libvlc: Lancement de vlc avec l'interface par défaut. Utiliser « cvlc » pour démarrer VLC sans interface.
error: XDG_RUNTIME_DIR not set in the environment.
[0150f930] skins2 interface error: cannot initialize OSFactory
[0150f930] [cli] lua interface: Listening on host "*console".
vlc: ./interface/vmcs_host/vc_vchi_gencmd.c :160 : vc_vchi_gencmd_init:  l'assertion « success == 0 » a échoué...

With VLC it works fine for me to play video on the display

When you run a program from the exec node it does not give access to the display by default. You can try this configuration to give vlc access to your display and check if it works

export DISPLAY=:0 && vlc /home/pi/Desktop/flip2.mov

Ok, thanks a lot Krambriw,

It's much better, but my video start at each msgpayload received.

I d'ont know why, because i put a condition. Start exec when payload Video it's received...

That is another thing you have to solve. Now your video is paying :wink:

Yes for sure, Thanks a lot Krambriw :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.