Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5368

Troubleshooting • Re: VLC Player not working when included in startup script

$
0
0
It looks like maybe I'm not supposed to have the "+" when using the mpg123. But I tried that and received a similar error but this time it's because it's just looking for a file named song, and not what song= from above.

[src/streamdump.c:stream_open():600] error: failed to open file: song: No such file or directory

I also tried this:

Code:

from gpiozero import MotionSensorimport mpg123pir = MotionSensor(23)                   while True:            pir.wait_for_motion()            mpg123 /home/jasonc/Music/airplane.mp3
which gives this error:

Code:

Traceback (most recent call last):  File "/home/jasonc/Motion.py", line 9, in <module>    mpg123 /home/jasonc/Music/airplane.mp3NameError: name 'home' is not defined

That's because the line below is almost certainly incorrect.

Code:

            mpg123 /home/jasonc/Music/airplane.mp3
Firstly "mpg123" is the module name. You'd not normally call that, instead you'd do something like

Code:

mgp123.somefunction(some, arguments)
Secondly, python is treating "/home/jasonc/Music/airplane.mp3" as a variable name when it should likely be a string.

So check the docs for the module and adjust accordingly.

Once that has been resolved be aware that you'll likely hit problems with the sound sub-system not being initialised. It only gets initialised once a user is logged in and only for that user. Some methods will run your code before that happens (rc.local*, cron* @reboot, systemd*** to name three).

The easiest solution is to have the OS configured to auotboot to the desktop then use autostart or wayfire.ini to start your script. See the relevant bits of Running A Program At Start Up A Beginner's Guide****

Not sure what you meant by "bash" in your OP but if you meant $HOME/.bashrc that's not a sensible thing to do as that gets run more often than you migth think. *****

As for the guess made above that "This looks like yet-another-variation of the "DISPLAY isn't set when run from rc.local (or similar, early in the boot/startup sequence)" thingie." Not having the DISPLAY environment variable set may be part of the problem but simply setting it is unlikely the whole solution. Not only does that have to be set to the correct thing but the desktop it points to needs to be running and accepting connections from outside the logged in session.

*: No, not local.rc
**: @reboot cron jobs run earlier in the boot sequence than you might expect. Basically they run as soon as the cron daemon has started so not everything will be available.
***: Very much depends on what you put in Wants, WantedBY, Before, and After in the service definition. You may also hit issues if you use the default user as that's root and they won't be able to use a different user's sound setup.
****: Full disclosure - I wrote that.
*****: On auto login before the desktop starts, at every login via ssh, every time you open a terminal window in the desktop, and many more.

Statistics: Posted by thagrol — Tue Apr 30, 2024 1:01 am



Viewing all articles
Browse latest Browse all 5368

Trending Articles