Hello to everybody! Some days without posting, but not without making inventions for fun and profit.
I'm enjoying to deploy a geo-social app, but about this i will write another day. Today, I want to speak about Groveeshark. I like Grooveshark, imho is best than Spotify. But, I've got a problem. I'm poor .. so I can't pay 9$/mo. by listen it in my mobile device. Also I want listen it in other devices that haven't got support ;)
So, i've thinking about this problem .. and i've found a workaround: streaming my favourite Groveeshark station through icecast. It's easy and now i can listen it in my phone, in my Wii, in my Xtreamer ...
Obviously, we need Grooveshark. So, we start a Grooveshark client (desktop or web) in our linux desktop and choose our favorite radio station.
Yes, we need an icecast2 server. So, go to install it.
Now, we've got a Grooveshark client that is playing music in our desktop and a streaming server that is ready to relay audio. So, we need connect our music with our streaming server. How?
It's very easy. We only need three tools: arecord, lame and ezstream and put all together.
This is the command. With arecord we record the current PCM output, with lame we reencode the WAV stream into a MP3 stream, finally, with ezstream we send the audio to the icecast server.
The ezstream_groove.xml file can be some like this:
Our icecast server will be played in a lot of devices:
- Android with Online Raadio
- Homebrew Wii with WiiRadio
- Any VLC compatible device
- ...
Finally, if we want deploy this idea, we need make it stable. How make it?
First, we making a script that relaunch the stream if fails.
P.S. You can try your invents with this: streaming OGG and use a HTML5 client and others ...
I'm enjoying to deploy a geo-social app, but about this i will write another day. Today, I want to speak about Groveeshark. I like Grooveshark, imho is best than Spotify. But, I've got a problem. I'm poor .. so I can't pay 9$/mo. by listen it in my mobile device. Also I want listen it in other devices that haven't got support ;)
So, i've thinking about this problem .. and i've found a workaround: streaming my favourite Groveeshark station through icecast. It's easy and now i can listen it in my phone, in my Wii, in my Xtreamer ...
Step 1: The audio source
Obviously, we need Grooveshark. So, we start a Grooveshark client (desktop or web) in our linux desktop and choose our favorite radio station.
Step 2: The icecast2 server
Yes, we need an icecast2 server. So, go to install it.
apt-get install icecast2We don't need any special config, only change the default password and start it.
Step 3: The magic command
Now, we've got a Grooveshark client that is playing music in our desktop and a streaming server that is ready to relay audio. So, we need connect our music with our streaming server. How?
It's very easy. We only need three tools: arecord, lame and ezstream and put all together.
arecord -f cd -t wav | lame - - | ezstream -c /etc/default/ezstream_groove.xml
This is the command. With arecord we record the current PCM output, with lame we reencode the WAV stream into a MP3 stream, finally, with ezstream we send the audio to the icecast server.
The ezstream_groove.xml file can be some like this:
<ezstream>
<url>http://yourhost:8000/groove</url>
<sourcepassword>YourPassword</sourcepassword>
<format>MP3</format>
<filename>stdin</filename>
<stream_once>1</stream_once>
<svrinfoname>GrooveIT</svrinfoname>
<svrinfourl>http://appinventorlife.blogspot.com</svrinfourl>
<svrinfogenre>All</svrinfogenre>
<svrinfodescription>GrooveShark Radio</svrinfodescription>
<svrinfobitrate>128</svrinfobitrate>
<svrinfoquality>3.0</svrinfoquality>
<svrinfochannels>2</svrinfochannels>
<svrinfosamplerate>44100</svrinfosamplerate>
<svrinfopublic>1</svrinfopublic>
</ezstream>
Step 4: Listen your station
Our icecast server will be played in a lot of devices:
- Android with Online Raadio
- Homebrew Wii with WiiRadio
- Any VLC compatible device
- ...
Step 5: Making it stable
Finally, if we want deploy this idea, we need make it stable. How make it?
First, we making a script that relaunch the stream if fails.
#!/bin/bashSecond, Grooveshark stops the music if detects inactivity. So, we need simulate activity in our desktop. For this, we need a random mouse movement :)
while true
do
echo "Streaming ..."
arecord -f cd -t wav | lame - - | ezstream -c /etc/default/ezstream_groove.xml > /dev/null
done
#!/usr/bin/pythonThis is all ... enjoy it :)
import random
import time
from Xlib import X, display
while 1:
disp = display.Display()
scr = disp.screen()
root = scr.root
root.warp_pointer(random.randint(100,800),random.randint(100,600))
disp.sync()
time.sleep(10);
P.S. You can try your invents with this: streaming OGG and use a HTML5 client and others ...