Workaround to play internet radio on the jukebox player

Tutorials, tips and tricks.

Moderator: moderators

Workaround to play internet radio on the jukebox player

Postby ccandreva » Wed Aug 25, 2010 11:42 pm

OK, this is a little -- involved. However, it works, at least for me on Linux (Fedora).

I save the URL of the station in a .m3u file, and use mplayer to to play the streams. However, since mplayer can't write directly to STDOUT, we'll need a shell script to do this. It creates a named pipe, writes to it, and `cat`s the pipe. I modified this from a script used for Asterisk. Save the following as a shell script called mpstream in /var/subsonic/transcode:
Code: Select all
#!/bin/bash

PIPE="/tmp/subsonic-moh-pipe"

if [ -p $PIPE ]; then
  pkill mplayer
  rm $PIPE
fi
mknod $PIPE p

mplayer -quiet -really-quiet -ao pcm:file=$PIPE -playlist "$@" | cat $PIPE
rm $PIPE


Make sure mpstream is mode 755 (or at least executable by the user Subsonic runs as).

Under General settings, add .m3u to the Music Mask. Now add a transcoder for "m3u > wav" This just needs a single transcode step,
Code: Select all
mpstream %s


And that's it. Load and play your .m3u file and you should hear your stream. The .m3u files need to be saved with your music (mp3, flac, etc) files, NOT with playlists.
User avatar
ccandreva
 
Posts: 104
Joined: Fri May 28, 2010 8:22 pm

Postby j3tblk » Wed Sep 15, 2010 8:29 am

thanks for the info. Any pointers for Windows?
j3tblk
 
Posts: 117
Joined: Thu Jun 03, 2010 3:51 pm

Postby ccandreva » Wed Sep 15, 2010 11:04 am

Sorry, never touch the stuff. :-)
User avatar
ccandreva
 
Posts: 104
Joined: Fri May 28, 2010 8:22 pm

Workaround to play internet radio on the jukebox player

Postby soloport » Tue Sep 28, 2010 5:57 am

Everything works on the command line:
Code: Select all
/srv/httpd/vhosts/subsonic/transcode/mpstream "/home/audio/Internet Radio/Some Station.m3u"


This produces lots of unicode all over the console (until Ctrl-C) as expected.

Entering the following at the command line also works (audio out):
Code: Select all
mplayer -playlist "/home/audio/Internet Radio/Some Station.m3u"


However, subsonic freezes (and no audio):
Code: Select all
$ ps -eww f
30259 pts/1    Sl     0:15 java -Xmx100m -Dsubsonic.home=/srv/httpd/vhosts/subsonic -Dsubsonic.host=0.0.0.0 -Dsubsonic.port=8888 -Dsubsonic.contextPath=/ -Dsubsonic.defaultMusicFolder=/home/audio -Dsubsonic.defaultPodcastFolder=/srv/httpd/vhosts/subsonic/podcast -Dsubsonic.defaultPlaylistFolder=/srv/httpd/vhosts/subsonic/playlists -jar subsonic-booter-jar-with-dependencies.jar
30331 pts/1    S      0:00  \_ /bin/bash /srv/httpd/vhosts/subsonic/transcode/mpstream /home/audio/Internet Radio/Some Station.m3u
30337 pts/1    S      0:00      \_ cat /tmp/subsonic-moh-pipe


Code: Select all
Name     Convert from     Convert to     Step 1
m3u > wav      m3u      wav      mpstream %s


Anything else I should try?

Thanks.
soloport
 
Posts: 3
Joined: Tue Sep 28, 2010 4:33 am

Postby ccandreva » Tue Sep 28, 2010 11:09 am

It looks like mplayer isn't running, as it doesn't show in the 'ps' output.

Trying putting the full path to mplayer into the script, ie /usr/bin/mplayer -quiet .....
User avatar
ccandreva
 
Posts: 104
Joined: Fri May 28, 2010 8:22 pm

Workaround to play internet radio on the jukebox player

Postby soloport » Wed Sep 29, 2010 1:44 am

Thanks for the quick reply.

Fixed with:
Code: Select all
echo "nolirc=yes" >> ~/.mplayer/config

Error messages "mplayer: could not connect to socket" persisted even after installing lirc, so, disabled.
soloport
 
Posts: 3
Joined: Tue Sep 28, 2010 4:33 am

Possible in OSX?

Postby bull » Sat Nov 13, 2010 7:19 am

Has anyone had any luck getting this to work with Subsonic on OSX? I've had to make a few modifications to the code (killall and mkfifo) as seen here:

Code: Select all
#!/bin/bash

PIPE="/tmp/subsonic-moh-pipe"

if [ -p $PIPE ]; then
  killall mplayer
  rm $PIPE
fi
mkfifo $PIPE

/opt/local/bin/mplayer -quiet -really-quiet -ao pcm:file=$PIPE -playlist "$@" | cat $PIPE
rm $PIPE


If I try running this from the command line I can see a process of mplayer running and the temp pipe is created, but I get a heap of unicode characters spewing out similar to soloport...and when I try launching it from Subsonic the only thing logged is:

Code: Select all
[11/13/10 8:06:59 PM NZDT]   INFO   JukeboxService   Starting jukebox player on behalf of bull
[11/13/10 8:06:59 PM NZDT]   INFO   PlaylistInputStream   bull listening to "_RADIO/SomaFM - Indie Pop Rocks.m3u"
[11/13/10 8:06:59 PM NZDT]   DEBUG   JukeboxService   stateUpdated : OPENING:-1:java.io.BufferedInputStream@1dab2ba7
[11/13/10 8:06:59 PM NZDT]   WARN   JukeboxService   Error in BasicPlayer.play()


Any ideas? Thanks!
bull
 
Posts: 4
Joined: Sat Nov 13, 2010 7:10 am

Re: Possible in OSX?

Postby soloport » Sat Jan 01, 2011 4:46 am

bull wrote:Any ideas? Thanks!


Did you give the above fix a try? Here again,

Code: Select all
echo "nolirc=yes" >> ~/.mplayer/config


The problem is mplayer expects lirc, so it needs to be disabled.
soloport
 
Posts: 3
Joined: Tue Sep 28, 2010 4:33 am

Re: Workaround to play internet radio on the jukebox player

Postby phartl » Fri Sep 13, 2013 9:13 am

Hi
Can you tell me where I have to put this code to ?
echo "nolirc=yes" >> ~/.mplayer/config

My subsonic does not play the inet stream (m3u)

regards
Patrick
phartl
 
Posts: 2
Joined: Fri Sep 13, 2013 9:08 am

Re: Workaround to play internet radio on the jukebox player

Postby boxjellyfish » Sat Jan 11, 2014 10:49 am

Hi guys,

For windows i've used the following trick:

- put 2 php files on the subsonic server with the following code

One to start the radio:
Code: Select all
//php file to start the radio on the server
$argument=$_GET["radio"];
echo "<pre>".shell_exec("psexec \\\\<lokal user> cmd.exe /C 123456 & start.bat $argument")."</pre>";


One to stop the radio:
Code: Select all
//php file to stop the radio on the server
echo "<pre>".shell_exec("psexec \\\\<lokal user> cmd.exe /C 123456 & stop.bat")."</pre>";


- add 2 batch files which startup vlc with radiostream. The radiostream is selected by the given argument.

example of the start.bat file
Code: Select all
echo off
echo starting %1
rem first kill all vlc instances.
taskkill /f /im vlc.exe
ping -n 3 127.0.0.1 > NUL
taskkill /f /im vlc.exe

rem Add radio stations. radio.php?radio=[radio]
rem will be used to switch between radiostartion
SET STREAM=http://8623.live.streamtheworld.com:80/SKYRADIO_SC
GOTO CASE_%1
:CASE_SKY
    SET STREAM=http://8623.live.streamtheworld.com:80/SKYRADIO_SC
    GOTO END_SWITCH
:CASE_CAZ
    SET STREAM=http://81.23.249.10/caz_audio_01
    GOTO END_SWITCH
:CASE_ARROW
    SET STREAM=http://81.23.249.10/ArrowAudio02
    GOTO END_SWITCH
:CASE_CANDLELIGHT
    SET STREAM=http://ice1.streamzilla.jet-stream.nl:8000/ilsemedia=ice7
    GOTO END_SWITCH
:CASE_80S
    SET STREAM=http://7639.live.streamtheworld.com:80/977_80_SC
    GOTO END_SWITCH
:CASE_70S
    SET STREAM=http://stream-45.shoutcast.com:80/all_hit_70s_skyfm_mp3_96kbps
    GOTO END_SWITCH
:CASE_DANCEWITHME
    SET STREAM=http://stream.radioextra-bg.net:8000/dancewithme
    GOTO END_SWITCH
:CASE_FRESHFM
    SET STREAM=http://stream12.freshfmonline.com/
    GOTO END_SWITCH
:CASE_MNM
    SET STREAM=http://mp3.streampower.be/mnm-high.mp3?rand=134
    GOTO END_SWITCH
:CASE_QMUSIC
    SET STREAM=http://vip1.str.reasonnet.com/qmusic.wma.96
    GOTO END_SWITCH
:CASE_RADIO1
    SET STREAM=http://icecast.omroep.nl/radio1-bb-mp3
    GOTO END_SWITCH
:CASE_RADIO2
    SET STREAM=http://icecast.omroep.nl/radio2-bb-mp3
    GOTO END_SWITCH
:CASE_TOP2000
    SET STREAM=http://icecast.omroep.nl/radio2-top2000-mp3
    GOTO END_SWITCH
:CASE_RADIO3
    SET STREAM=http://icecast.omroep.nl/3fm-bb-mp3
    GOTO END_SWITCH
:CASE_FUNX
    SET STREAM=http://icecast.omroep.nl/funx-bb-mp3
    GOTO END_SWITCH
:CASE_FUNXHIPHOP
    SET STREAM=http://icecast.omroep.nl/funx-hiphop-bb-mp3
    GOTO END_SWITCH
:CASE_REGGEA101
    SET STREAM=http://eu4.101.ru/c5_5_128?st=&amp;t=
    GOTO END_SWITCH
:CASE_ROOTSREGGEA
    SET STREAM=http://stream-102.shoutcast.com:80/rootsreggae_skyfm_mp3_96kbps
    GOTO END_SWITCH
:CASE_SKY80S
    SET STREAM=http://stream-39.shoutcast.com:80/the80s_skyfm_mp3_96kbps
    GOTO END_SWITCH
:CASE_BRUSSEL
    SET STREAM=http://mp3.streampower.be/stubru-high
    GOTO END_SWITCH
:CASE_TOPHITS
    SET STREAM=http://stream-20.shoutcast.com:80/tophits_skyfm_mp3_96kbps
    GOTO END_SWITCH
:CASE_538DD
    SET STREAM=http://82.201.100.10:8000/RD01_538_Dancedepartment
    GOTO END_SWITCH
:CASE_538HITZONE
    SET STREAM=http://82.201.100.10:8000/WEB11
    GOTO END_SWITCH
:CASE_JUIZE
    SET STREAM=http://82.201.100.9:8000/juizefm
    GOTO END_SWITCH
:CASE_PARTY
    SET STREAM=http://82.201.100.10:8000/WEB16
    GOTO END_SWITCH
:CASE_538
    SET STREAM=http://82.201.100.9:8000/radio538
    GOTO END_SWITCH
:CASE_53L8
    SET STREAM=http://82.201.100.10:8000/WEB21
    GOTO END_SWITCH
:CASE_SKYLOVESONGS
    SET STREAM=http://8623.live.streamtheworld.com:80/SKYLOVEAAC_SC
    GOTO END_SWITCH
:CASE_SKYSEASON
    SET STREAM=http://8593.live.streamtheworld.com:80/SEASONALAAC_SC
    GOTO END_SWITCH
:CASE_OMROEPBRABANT
    SET STREAM=mms://wm.media53.kpnstreaming.nl/kpn=OmroepBrabantL=OmroepBrabantHq
    GOTO END_SWITCH
rem *************************************************
rem    reggea
rem *************************************************
:CASE_BIGUP
    SET STREAM=http://radio.bigupradio.com.:8000/listen.pls
    GOTO END_SWITCH
:CASE_REGGEAKINGS
    SET STREAM=http://www.raggakings.net/listen.m3u
    GOTO END_SWITCH
:CASE_JAMAICAN
    SET STREAM=http://www.jamaicanradio.info/live.m3u
    GOTO END_SWITCH
:CASE_BIGVIBES
    SET STREAM=http://streams.bigvibez.com:7000/listen.pls
    GOTO END_SWITCH
:CASE_REGGEAME
    SET STREAM=http://streamingpulse.tv/sc10/tunein.php/reggaeme/playlist.pls
    GOTO END_SWITCH
:CASE_M2REGGEA
    SET STREAM=http://www.m2radio.fr/pls/m2sunshine_winamp.m3u
    GOTO END_SWITCH
:END_SWITCH

rem change this location if VLC is located in another directory
set VLC_LOC="\Program Files (x86)\VideoLAN\VLC"
c:
cd %VLC_LOC%
vlc.exe %STREAM%



Example of the stop.bat file

Code: Select all
rem try to kill vlc.
taskkill /f /im vlc.exe
ping -n 3 127.0.0.1 > NUL
rem and try again to be sure it stopped
taskkill /f /im vlc.exe


Now you can add internet radio to your subsonic configuration with URL's like this:
Code: Select all
http://<host of subsonic server>:<port>/<subdir>/radio.php?radio=JUIZE


After pressing the link vlc will be opened with the radio stream you choose. You can make different links for server side radio and client side radio.

To control the radio with a mobile device you can use the app "Remote Launcher" and startup the batch files.

This trick works for several month flauwless..
boxjellyfish
 
Posts: 2
Joined: Sat Jan 11, 2014 9:59 am

Re: Workaround to play internet radio on the jukebox player

Postby votti » Sun Jan 25, 2015 6:34 pm

Hi guys,

Does this still work for the current subsonic?
I run subsonic on debian and I get an Java error when trying to play something:
Error in jukebox: java.io.EOFException

Any idea what could be the cause for this one?

Cheers an thanks!
votti
 
Posts: 5
Joined: Wed Jan 02, 2013 9:35 pm

Re: Workaround to play internet radio on the jukebox player

Postby henrikp » Wed Jan 20, 2016 5:12 pm

The only logical course is to awaken this thread once more. Everything else works but it seems to me that the transcoding settings are hardcoded for jukebox mode, atleast in the current releases. The m3u file is Always executed by ffmpeg in jukebox mode but once I change it back to the web player mpstream executes mplayer and starts playing on the server. But since there is no redirection in that mode, the sound is sent to the void.

TL;DR - Are the transcoding settings for the jukebox mode set in stone or can I change them as well?
henrikp
 
Posts: 7
Joined: Thu Aug 04, 2011 6:53 am


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 21 guests