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

Troubleshooting • MPG123 module not found when script ran at root level

$
0
0
Hello,

I'm trying to get a random mp3 to play with motion activation. I then want that script to start on reboot.

I was able to write a script using VLC player. But had some issues on the startup part. I used all possible methods to start the script on boot, but none worked. It did look like I could get the script to run, but the VLC player seemed to not be working. I read and was told this is a known issue with VLC player when trying to get it to open on login. So I've moved on to MPG123. I wrote another script that works, but again can't get any of the startup methods to work. The current issue seems to be that mpg123 only wants to run at the user level. When I try to run it at the root level, I get a module not found error. This seems to be the sticking point because all the start script on startup methods I have found seem to need to run the script with sudo. Not sure what to do. I will post my script, but won't post all the various commands I've written in all the different efforts- but the common theme is that it can't find the mpg123 module when ran with sudo. I tried installing mpg123 at the root level but that throws up all kinds of warnings. Thank you!

Also- omxplayer looks like it is no longer supported, so I can't use that. And I tried playing the mp3s with pygame and they sounded terrible. So I'd rather not use that.

Also- I tried following instructions on setting up a virtual environment to see if that worked. I was able to insatll mpg123, but then I started getting errors that it could not find a bunch of otherstuff needed #from memory# lpgio pig-something, several things.... So didn't know where to proceed from there.

Code:

from gpiozero import MotionSensorimport mpg123import osimport randompir = MotionSensor(23)                   while True:    pir.wait_for_motion()    randomfile = random.choice(os.listdir("/home/jasonc/Music/"))    file = '/home/jasonc/Music/'+randomfile    os.chdir('/home/jasonc/Music/')    os.system("mpg123 " + file)    

Statistics: Posted by jasonco — Mon Apr 29, 2024 4:18 am



Viewing all articles
Browse latest Browse all 3552

Trending Articles