Background Music [Continued from Help/Support]
-
Just to add, was looking for a way to enable and disable the background music while in emulation station and creating a way for it to stick when rebooting. Don't know if there is a better way of doing it but I created two simple scripts . One that would kill the python background music and rewrite the rc.local file and the other that would start the python background script and rewrite the rc.local file. I then added those scripts to the retropie settings menu. Works well. Thanks again!
-
@HoolyHoo I may have a slightly less hacky-way to put it together, I'll do some checking with it (theoretically we could just abuse os.path.exists as part of the loop, to see if a file "disablemusic" exists. The script would then just never play music as long as that file exists, and the shell scripts would just need to create and erase that specific file rather than editing rc.local).
I'm working on the quick fix for starting with one specific song now; I have it coded but I need to test it on the cab downstairs, assuming no problems I'll have it posted within 30 minutes.
-
Thanks @Livewire !
-
Made it in JUST under 30 minutes (well, at least before I started typing my reply) :) 1.02's up:
-
/home/pi/PyScripts/DisableMusic . If this location exists (either as a folder, OR as a file), the script will cease to play music. Once found, it waits 15 seconds before checking again, so after removing that file it may take up to 15 seconds for the script to resume playing music. Did this mostly because if you're disabling music, you're probably disabling it for a while, not just for 2 or 3 seconds, so why check it every second.
-
startmusic="" (near the top of the script). Stick in the exact case-sensitive filename, and if that file is found in the bgm list, it will always play first when the script starts.
Invariably about 3 seconds after I posted it to pastebin I did notice that I have startmusic in the "#local variables" section instead of config; it's there, just go down a few lines :) Also, if you don't want it to check /home/pi/PyScripts/DisableMusic, such as if you have it in a different install location, the lines that check for that file are 66 and 70; make sure they match, but you can change them freely.
-
-
Thanks for this script @Livewire . I've been playing around with it a bit today, works great.
I'm still very much a beginner with python and I'm a bit stuck finding a way to stop the music if I quit out of emulationstation.
At the moment the music still plays after ES has exited, I don't wan't to quit the script, just stop the music until ES starts again.
I'm trying to do a bit more reading to understand your code for myself but if you made another update could you add that feature?
thanks again
-
@mike I might not get a good chance to test it before tomorrow night but I should be able to do that, it's another use-case I didn't think of :)
-
@mike Done, ended up having time to test before the weekly gamer meetup :) Added a few extra comments to (hopefully) help with dissecting the code as well.
Changes:
- Just what Mike wanted; the music stops when ES is not running, and resumes within 10 seconds of it restarting.
- I moved startsong up into the config section where it should have been, cause I'm a derp.
-
That's great, thanks. The comments really help too.
-
@Livewire said in Background Music [Continued from Help/Support]:
- /home/pi/PyScripts/DisableMusic . If this location exists (either as a folder, OR as a file), the script will cease to play music. Once found, it waits 15 seconds before checking again, so after removing that file it may take up to 15 seconds for the script to resume playing music. Did this mostly because if you're disabling music, you're probably disabling it for a while, not just for 2 or 3 seconds, so why check it every second.
This is a horrible idea. This means that if the file exists on an external hard drive, the hard drive will never spin down because it's constantly being accessed. This also bad if your pi does not have a constant power source.
How about instead of looking for a file, it simply kills the script off and restarts it?
-
To be truly honest, that I'm not actually sure how to do (without running an entirely separate script I mean, since there's not really a way to have a python script kill and restart itself at a later time that I know of). If you've got it running on an external HDD, I'd recommend not using 1.03 then.
-
Hi. My English is very bad. Could you make a video tutorial? In this way, we would see how to do it and we would see progress.
-
I followed step by step and it does not work. Version 3.7 Retropie in a Raspberry 3b. .mp3 and .ogg files. A video tutorial clarify everything. Thank you.
-
I tried as well to no avail.
-
Hi! I need help, all works for me if I use in the console :
sudo python /home/pi/PyScript/Test1.py
But when I reboot the py, the music dont work.
This is my /etc/rc.local file
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
"(sudo python /home/pi/PyScript/Test1.py) &"
exit 0 -
@Nayin Ok the problem are the "", sorry ah ah ah :P
-
Music dont stop when I use the amiga emulator.
Can you help me? -
Just add the Amiga emulator to line 25 in the script.
-
@HoolyHoo It is added by default, the same problem with pifba and it this also added :(
-
Ok the error is the "2", in uae4all2.
Delete the "2" in line 25 and works. Thx -
Amazing script, it work like a charm !!!
It's possible to configure buttons for activate and desactivate the script ??? or for configure a fast - rewind audio player ???
It would be amazing !!!!
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.