Streaming internet radio when browsing for games and on screensaver?
-
@mitu
Sure. Here you goecho -n pause | nc -U /tmp/radio.sock >/dev/null 2>&1
-
@nowarrivinghere You might be missing the
nc
utility. Does the command works if you run it in a terminal ? Just typenc
and see if you get any error. -
pi@raspberrypi:~ $ nc usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-O length] [-P proxy_username] [-p source_port] [-q seconds] [-s source] [-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol] [-x proxy_address[:port]] [destination] [port]
-
@nowarrivinghere So
netcat
is installed. What happens if you run the command from the onstart file manually, after ES is started and the music plays ? It should pause the music.echo -n pause | nc -U /tmp/radio.sock >/dev/null 2>&1
Can you run the command from a SSH session and see what's the outcome ? If it works (i.e. music is paused), try starting a game and (after you get thrown back to ES ) then paste the contents of the
/var/shm/runcommand.log
file, we might have some clues there. -
@jonnykesh said in Streaming internet radio when browsing for games and on screensaver?:
I wish I could remember who wrote it so I could give them credit.
Not written completly just modified a bit... but I introduced here.... with correspondending source ;)
-
Okay, I just used SSH to try the pause command while the music was playing. I've waited about 90 seconds. Music is still playing and the SSH window is unresponsive.
-
@nowarrivinghere Sorry, forgot about removing the redirection. Execute this:
ls -l /tmp/radio.sock echo -n pause | nc -U /tmp/radio.sock
I suspect it might be a permission problem.
-
Still fails to pause and leaves the window stuck.
pi@raspberrypi:~ $ ls -l /tmp/radio.sock srwxr-xr-x 1 pi pi 0 Oct 4 16:42 /tmp/radio.sock pi@raspberrypi:~ $ echo -n pause | nc -U /tmp/radio.sock
-
@nowarrivinghere I have no idea why it does that - maybe Stretch has a different version of VLC that's not the same as the one I tested and the old interface doesn't work anymore ?
Just to check if there is a problem with newer versions, kill the VLC that is started via the autostart with
killall vlc
, then start the playback directly from thessh
session, by runningvlc -I oldrc --rc-unix /tmp/radio.sock -Zq --no-video /home/pi/radio/list.txt
You should get the radion playing this way with logging from VLC on the terminal.
Now, from a 2nd SSH session, run theecho
command that's giving you trouble and see if it pauses the stream or any error appears in the 1st terminal, where VLC is running.Other than that, maybe the output of
/dev/shm/runcommand.log
from starting a game might be of use. -
Okay, this is interesting, I opened SSH Window 1, killed vlc, and reopened it via the command you gave. Then, in SSH Window 2, I ran the pause command. It appeared to sit there with the music still playing just as before. However, I then did a CTRL+C in Window 2 and it paused. Then I used the pause command in Window 2 again. Once again, it just sat there silently. Then I did CTRL+C and sure enough it started playing music again. Also, here is the output that appeared in Window 1.
status change: ( new input: http://listen.ai-radio.org:8000/128.ogg?cc=US&now=1507110308.444& ) status change: ( play state: 3 ) pause: returned 0 (no error) status change: ( pause state: 3 ): Pause status change: ( pause state: 4 ) pause: returned 0 (no error) status change: ( play state: 2 ): Play status change: ( play state: 3 ) pause: returned 0 (no error) status change: ( pause state: 3 ): Pause status change: ( play state: 3 ) pause: returned 0 (no error)
EDIT: I decided to just place the script that jonnykesh brought us inside my
runcommand-onstart.sh
andruncommand-onend.sh
with thempg123
replaced withvlc
. That seems to work and perform the function of thepause
command on the cases I have tried so far. Its probably not as efficient as the actual vlc controls, but I haven't noticed a delay from a human perspective. It is more efficient than just using thekill all
command and then that command we added inautostart.sh
and restarting vlc every time though, which was my backup plan and did introduce a delay. Would be nice to have access to the other vlc controls, but I can't think of anything else to try right now. -
@nowarrivinghere This means the
netcat
commands you run in the 2nd window reads the pause command but it doesn't send it right away and awaits further input.
I'll do some testing with the version in Stretch to see if it behaves differently than the one in the Jessie release, but glad you got it working with the alternate start/stop command. -
Ok, found out the difference - tested on a Stretch system. The
netcat
command doesn't return and still waits for input from the tty. To force it to close the input, using-N
seems to do the trick.
@NowArrivingHere you can try changing the on-start/on-end commands toecho -n pause | nc -UN /tmp/radio.sock
Unfortunately the
-N
option doesn't exist in the Jessie version ofnetcat-openbsd
, I'll see if we can ditchnetcat
completely and use something else. -
OK, I've found a way to ditch
netcat
- by replacing it withsocat
. I have updated the instructions steps with the new commands (steps 2 and 3, plus the pre-requisites).
This should work on both Jessie and Stretch - and possibly other systems. -
@mitu
Thanks mate. It is pausing and playing properly now. -
Pi Model or other hardware: 3B
Power Supply used: Original Raspi
RetroPie Version Used : 4.4.12
Built From: Retropie Website
USB Devices connected: Keyboard
Controller used: PS4Hi there! I ran the script and it is working fantastic! Thankyou. However I was wondering if is there a way to control/adjust the volume while in ES. If not, if is there a way to pre-configure the volume level in the script. Great work!
-
@mtib Emulationstation has an audio volume knob which allows you to change the volume - doesn't it work for the background music ?
Alternatively you can add the--gain
parameter to thempg123
to set the volume (0-100):# to set the volume to 40% mpg123 --gain 40 [..other parameters following..]
-
@mitu @mtib You can try out
mpg123 -f
parameter.... The gain is a deprecated function. But I've to admit never used the gain function ;)mpg123 -f ##### 32768 - Volume 100% 29484 - Volume 90% 26208 - Volume 80% 22932 - Volume 70% 19656 - Volume 60% 16380 - Volume 50% 13104 - Volume 40% 9828 - Volume 30% 6552 - Volume 20% 3276 - Volume 10%
-
To mention .... in
mpg321
the--gain
option is documentated ;) -
Thanks!
@mtib Emulationstation has an audio volume knob which allows you to change the volume - doesn't it work for the background music ?
Right, but then will affect the UI fx level as well.
Ok I am missing something, when I type this command in Putty, I get:
# pi@retropie:~ $ mpg123 -f 32768 You made some mistake in program usage... let me briefly remind you: High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 version 1.23.8; written and copyright by Michael Hipp and others free software (LGPL) without any warranty but with best wishes usage: mpg123 [option(s)] [file(s) | URL(s) | -] supported options [defaults in brackets]: -v increase verbosity level -q quiet (don't print title) -t testmode (no output) -s write to stdout -w f write output as WAV file -k n skip first n frames [0] -n n decode only n frames [all] -c check range violations -y DISABLE resync on errors -b n output buffer: n Kbytes [0] -f n change scalefactor [32768] -r n set/force samplerate [auto] -o m select output module -a d set audio device -2 downsample 1:2 (22 kHz) -4 downsample 1:4 (11 kHz) -d n play every n'th frame only -h n play every frame n times -0 decode channel 0 (left) only -1 decode channel 1 (right) only -m mix both channels (mono) -p p use HTTP proxy p [$HTTP_PROXY] -@ f read filenames/URLs from f -T get realtime priority -z shuffle play (with wildcards) -Z random play -u a HTTP authentication string -E f Equalizer, data from file -C enable control keys --no-gapless not skip junk/padding in mp3s -? this help --version print name + version See the manpage mpg123(1) or call mpg123 with --longhelp for more parameters and information.
-
@mtib said:
Ok I am missing something, when I type this command in Putty, I get:
You need to append the rest of the parameters - the filename/playlist for
mpg321
. You should add the-f <volume>
to the initial command used in the script.
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.