• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

Grooveshark Music Streaming For Windows Phone 7, WP7

Search This thread

Ikkari

Senior Member
Mar 18, 2009
318
28
Would it be possible with the current Marketplace restrictions to develop a streaming client for Grooveshark?

Nanogroove and GrooveFish did that on Windows Mobile, it would be great to have such a client on Windows Phone 7, i would definitely pay for such an app.

Also there is a thread going on, on the official Grooveshark forums but there is no official answer till now.
The official clients on iPhone and Android are coded really well and add a great value to the platform.

If you like Grooveshark help us put some pressure on them :D

http://forums.grooveshark.com/discussion/1262/Grooveshark-on-Windows-Phone-7
 
  • Like
Reactions: simon.b
G

GuestK00306

Guest
Would it be possible with the current Marketplace restrictions to develop a streaming client for Grooveshark?

Nanogroove and GrooveFish did that on Windows Mobile, it would be great to have such a client on Windows Phone 7, i would definitely pay for such an app.

Also there is a thread going on, on the official Grooveshark forums but there is no official answer till now.
The official clients on iPhone and Android are coded really well and add a great value to the platform.

If you like Grooveshark help us put some pressure on them :D

http://forums.grooveshark.com/discussion/1262/Grooveshark-on-Windows-Phone-7

I had a quick glance at the source for one of the Windows Mobile grooveshark applications. Looks like it just uses basic HTTP JSON requests to post/receive data, so it shouldn't really be an issue.

The only problem would be, what would you do while listening to Grooveshark? Because as soon as you want to do something else it has to stop :(
 

Ikkari

Senior Member
Mar 18, 2009
318
28
I know that there is no multitasking on WP7 and that only Zune can play in background. But as long you are in the app you can lock the screen an continue to listen to music, which would be totally enough for me.

Otherwise would there be a way to play the songs directly in the Zune player?
There is some kind of interaction with Zune and 3rd party apps, at least i can see some youtube videos and radio streams in my Zune player history.
 
G

GuestK00306

Guest
Otherwise would there be a way to play the songs directly in the Zune player?
There is some kind of interaction with Zune and 3rd party apps, at least i can see some youtube videos and radio streams in my Zune player history.

This could well be possible. I may have a look into doing this this weekend. There are too many differences in the old .NET Compact source code for a direct port, but it should be easy enough to get a proof of concept pretty quickly (assuming the device supports the data received from Grooveshark).
 

kingjovius

Member
May 2, 2010
27
0
but i would have thought zune pass is good enough? Then again, if youre in a country without zune pass that might be a problem (i dont have access to zune pass and am waiting :p)
 
G

GuestK00306

Guest
but i would have thought zune pass is good enough? Then again, if youre in a country without zune pass that might be a problem (i dont have access to zune pass and am waiting :p)

It is, but it's also £86 for the year. Grooveshark (via the internal APIs) is free.

edit: I managed to write a quick library to query Grooveshark and pull back some results. Unfortunately the MediaElement is having some trouble playing the MP3 stream when it really should be fine.

If anybody has any ideas why this isn't working, we would basically have a fully functional Grooveshark app :)
 

Attachments

  • GroovesharkTest.zip
    140.2 KB · Views: 358
Last edited:

CR1M1N4L

Member
May 15, 2010
42
5
www.dabasinskas.net
It is, but it's also £86 for the year. Grooveshark (via the internal APIs) is free.

edit: I managed to write a quick library to query Grooveshark and pull back some results. Unfortunately the MediaElement is having some trouble playing the MP3 stream when it really should be fine.

If anybody has any ideas why this isn't working, we would basically have a fully functional Grooveshark app :)

Wow, thanks. The playing fails because of AG_E_NETWORK_ERROR error. After some searching:
  • I found a suggestion to add &.mp3 to the end of the stream URL, but that didn't work for me.
  • I've also tried it on my HTC Mozart (with unplugged cable, since I've read that media streaming on the device doesn't work while it's connected to the PC), but that didn't work too.
  • I've tried to compare Grooveshark MP3 file/codec info with some other MP3 that I can play without any problems using MediaElement. I did it because WP7 supports only specific codecs. Unfortunately I haven't found any differences.
  • I've tried to extract Location header from the stream to get exact location to the file. Header doesn't exist.

Now I'm scared that it might be impossible to create Grooveshark player until we get update for WP7 API. :confused:

Anyhow, if you find anything to make it work, please let me know. I'm really interested into that.
 
G

GuestK00306

Guest
Wow, thanks. The playing fails because of AG_E_NETWORK_ERROR error. After some searching:
  • I found a suggestion to add &.mp3 to the end of the stream URL, but that didn't work for me.
  • I've also tried it on my HTC Mozart (with unplugged cable, since I've read that media streaming on the device doesn't work while it's connected to the PC), but that didn't work too.
  • I've tried to compare Grooveshark MP3 file/codec info with some other MP3 that I can play without any problems using MediaElement. I did it because WP7 supports only specific codecs. Unfortunately I haven't found any differences.
  • I've tried to extract Location header from the stream to get exact location to the file. Header doesn't exist.

Now I'm scared that it might be impossible to create Grooveshark player until we get update for WP7 API. :confused:

Anyhow, if you find anything to make it work, please let me know. I'm really interested into that.

I don't think it has anything to do with the encoding, but I did notice that these don't work:
http://download.linnrecords.com/test/mp3/recit.aspx (MP3)
http://download.linnrecords.com/test/wma/recit24bit.aspx (WMA, should work no matter what)

While this does:
http://wahiduddin.net/troubleshooting/testing.wma
http://wahiduddin.net/troubleshooting/testing.mp3

Something to do with the way the content is served. Maybe the web server is adding extra headers before sending the WMA/MP3 headers?
 

CR1M1N4L

Member
May 15, 2010
42
5
www.dabasinskas.net
I don't think it has anything to do with the encoding, but I did notice that these don't work:
http://download.linnrecords.com/test/mp3/recit.aspx (MP3)
http://download.linnrecords.com/test/wma/recit24bit.aspx (WMA, should work no matter what)

While this does:
http://wahiduddin.net/troubleshooting/testing.wma
http://wahiduddin.net/troubleshooting/testing.mp3

Something to do with the way the content is served.

There's no surprise two first ones aren't working. Even the browser tries to download them instead of streaming, while the next two ones streams in the browser. The GrooveShark urls also streams in the browser (like the second ones in your post), therefore you shouldn't take first to links in your post as an example since they are forced to be downloaded.

Maybe the web server is adding extra headers before sending the WMA/MP3 headers?

As for headers, here's GrooveShark stream response headers:
Code:
HTTP/1.1 206 Partial Content
X-Powered-By: PHP/5.1.6
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Sat, 26 Jul 1997 05:00:00 GMT
Content-Type: audio/mpeg
Etag: "403963618"
Accept-Ranges: bytes
Last-Modified: Wed, 29 Sep 2010 11:57:11 GMT
Content-Range: bytes 0-4617321/4617322
Content-Length: 4617322
Connection: close
Date: Sun, 02 Jan 2011 14:00:40 GMT
Server: lighttpd/1.5.0

And this is some other MP3 stream that WP7 loads correctly:
Code:
HTTP/1.1 206 Partial Content
Date: Sun, 02 Jan 2011 14:02:03 GMT
Server: Apache
Last-Modified: Sun, 07 Feb 2010 18:06:12 GMT
Etag: "443d05d-15180-4b6f0114"
Accept-Ranges: bytes
Content-Length: 86400
Content-Range: bytes 0-86399/86400
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: audio/mpeg

There are some extra headers, but I don't think that it should make any difference.

EDITED:

Just right after posting those headers here and reading my post I've noticed this header in GrooveShark's response:
Code:
Connection: close
I think that might cause the problem.
 
Last edited:
G

GuestK00306

Guest
EDITED:

Just right after posting those headers here and reading my post I've noticed this header in GrooveShark's response:
Code:
Connection: close
I think that might cause the problem.

I was thinking the same thing, probably causing the Stream to read all in one go. Problem here is that Silverlight restricts pretty much all HTTP headers so we can't override them :(

I did manage to get the stream to play by writing it to the Isolated Storage, then passing it onto the MediaElement:
Code:
void gf_CompleteStream(object sender, EventArgs e)
        {
            GroovesharkAPI.GroovesharkFunctionsEventArgs<GroovesharkAPI.ResponseObjects.Stream> gea =
                   e as GroovesharkAPI.GroovesharkFunctionsEventArgs<GroovesharkAPI.ResponseObjects.Stream>;

            WebClient wc = new WebClient();
            wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
            wc.OpenReadAsync(new Uri(gea.ResponseObject.result.url));

            this.txtStatus.Text = "Downloading MP3";
        }

        void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (store.FileExists("output.mp3"))
                {
                    store.DeleteFile("output.mp3");
                }
                using (var fs = new System.IO.IsolatedStorage.IsolatedStorageFileStream("output.mp3", System.IO.FileMode.Create, store))
                {
                    byte[] bytesInStream = new byte[e.Result.Length];
                    e.Result.Read(bytesInStream, 0, (int)bytesInStream.Length);
                    fs.Write(bytesInStream, 0, bytesInStream.Length);
                    fs.Flush();

                    this.mediaElement1.SetSource(fs);
                }
            }
        }

So it's definitely something to do with the way MediaElement handles the stream from the server. Another oddity in the API DLL is that the "getStreamUrlEx" method is returning the wrong song!
 

CR1M1N4L

Member
May 15, 2010
42
5
www.dabasinskas.net
I was thinking the same thing, probably causing the Stream to read all in one go. Problem here is that Silverlight restricts pretty much all HTTP headers so we can't override them :(

I did manage to get the stream to play by writing it to the Isolated Storage, then passing it onto the MediaElement:
Code:
void gf_CompleteStream(object sender, EventArgs e)
        {
            GroovesharkAPI.GroovesharkFunctionsEventArgs<GroovesharkAPI.ResponseObjects.Stream> gea =
                   e as GroovesharkAPI.GroovesharkFunctionsEventArgs<GroovesharkAPI.ResponseObjects.Stream>;

            WebClient wc = new WebClient();
            wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
            wc.OpenReadAsync(new Uri(gea.ResponseObject.result.url));

            this.txtStatus.Text = "Downloading MP3";
        }

        void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (store.FileExists("output.mp3"))
                {
                    store.DeleteFile("output.mp3");
                }
                using (var fs = new System.IO.IsolatedStorage.IsolatedStorageFileStream("output.mp3", System.IO.FileMode.Create, store))
                {
                    byte[] bytesInStream = new byte[e.Result.Length];
                    e.Result.Read(bytesInStream, 0, (int)bytesInStream.Length);
                    fs.Write(bytesInStream, 0, bytesInStream.Length);
                    fs.Flush();

                    this.mediaElement1.SetSource(fs);
                }
            }
        }

So it's definitely something to do with the way MediaElement handles the stream from the server. Another oddity in the API DLL is that the "getStreamUrlEx" method is returning the wrong song!

Could you check this app source? Maybe there's some problem with GrooveShark API in your test app.
 

sensboston

Recognized Developer
Nov 18, 2009
2,157
802
Boston, MA
I can suggest a little tricky solution (I've used to "hack" Google's TTS API). Yes, MediaElement can't play mp3 stream not ended by extension ".mp3". Not sophisticated design of course...
But you may create and use an URL redirector! You just need your own site running Apache with URL rewrite module installed.

Create directory, for example, "stream" and create inside a file ".htaccess" with content:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^.mp3$ http://download.linnrecords.com/test/mp3/recit.aspx[NE]

So, you should use the following url for ME Source property:
http://yoursite.com/streaming/file.mp3

MediaElement will determine the opened stream type as mp3 but real data will came from recit.aspx.

It's just an example; your implementation may differ. But I hope you've got my point.
 
  • Like
Reactions: Ikkari and CR1M1N4L

CR1M1N4L

Member
May 15, 2010
42
5
www.dabasinskas.net
I can suggest a little tricky solution (I've used to "hack" Google's TTS API). Yes, MediaElement can't play mp3 stream not ended by extension ".mp3". Not sophisticated design of course...
But you may create and use an URL redirector! You just need your own site running Apache with URL rewrite module installed.

Create directory, for example, "stream" and create inside a file ".htaccess" with content:


So, you should use the following url for ME Source property:
http://yoursite.com/streaming/file.mp3

MediaElement will determine the opened stream type as mp3 but real data will came from recit.aspx.

It's just an example; your implementation may differ. But I hope you've got my point.

Hey, thank you! It actually did the trick. In a day or two I'll try to release fully working player.
 
  • Like
Reactions: Ikkari

Ikkari

Senior Member
Mar 18, 2009
318
28
but i would have thought zune pass is good enough? Then again, if youre in a country without zune pass that might be a problem (i dont have access to zune pass and am waiting :p)

Thats the problem with Zune Pass in most countries it's not available right now. Also, Blade0rz mentioned it already earlier, Zune Pass is not that cheap.
I like Grooveshark better because i can use it with almost any platform, Win, Linux, MacOS, iOS, Android and maybe in near future with WP7 ^^
And you can upload your songs if Grooveshark don't have them, which i use a lot because I'm not listening to common music that much.

Hey, thank you! It actually did the trick. In a day or two I'll try to release fully working player.

That indeed would be awesome :D
 
G

GuestK00306

Guest
Hey, thank you! It actually did the trick. In a day or two I'll try to release fully working player.

Great! Looking forward to this :D

FYI, the "random song" thing seems to have fixed itself today. URLs are coming back just fine, so there shouldn't be any barriers any more :)
 

CR1M1N4L

Member
May 15, 2010
42
5
www.dabasinskas.net
Sorry guys, but I guess I won't be able to do the app because of lack of time. Anyhow, if anyone have enough time and skills to do the app, there's some stuff that might come in handy:

.htaccess file:
Code:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*?)/(.*?).mp3$ http://$1.grooveshark.com/stream.php?streamKey=$2 [NC]

Stream URL:
Yes, I know, there are more nicer ways to do that. This is just to understand how to do the redirect and use your host as a proxy:
Code:
var newUrl = "http://www.yourhost.net/groove/" + url.Host.Replace(".grooveshark.com", "") + "/" + url.Query.Replace("?streamKey=", "") + ".mp3";

Refactored API:
I've made some refactoring to the API (comments, split classes, code optimizations etc). You can download refactored API (source + binaries) here. I hope Blade0rz won't be mind.

Suggestions:
I was planning to make the app to look very similar to Zune player on WP7. I would make a panorama app. In the first page, for starters, "Search", "Radio" and "Playlists" menu items could be added. The second page would display history (album cover) and would open "Now playing" page when clicked. In the third page, by using WP7 toolkit top/new songs/albums could be should if that is possible by the API.

Notes:
Please be aware that it's unlikely that that sort of GrooveShark app would make it to the MarketPlace since using this API is against GrooveShark TOS, therefore it's a great chance they will comply.
 
G

GuestK00306

Guest
Sorry guys, but I guess I won't be able to do the app because of lack of time. Anyhow, if anyone have enough time and skills to do the app, there's some stuff that might come in handy:

I've been in touch with CR1M1N4L and I will be taking up this project, so thanks to him for refactoring some shoddy, 5 minute coding & helping with fixing the streaming issues :)

Please be aware that it's unlikely that that sort of GrooveShark app would make it to the MarketPlace since using this API is against GrooveShark TOS, therefore it's a great chance they will comply

Technically we should be OK as long as we don't use the Grooveshark trademarks (name/logo), but MS aren't likely to be very co-operative there, so everyone should be prepared to sideload this project! Shouldn't be a problem for anyone though given the relative ease of using Chevron.
 

Ikkari

Senior Member
Mar 18, 2009
318
28
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    I can suggest a little tricky solution (I've used to "hack" Google's TTS API). Yes, MediaElement can't play mp3 stream not ended by extension ".mp3". Not sophisticated design of course...
    But you may create and use an URL redirector! You just need your own site running Apache with URL rewrite module installed.

    Create directory, for example, "stream" and create inside a file ".htaccess" with content:
    RewriteEngine on
    Options +FollowSymlinks
    RewriteBase /
    RewriteRule ^.mp3$ http://download.linnrecords.com/test/mp3/recit.aspx[NE]

    So, you should use the following url for ME Source property:
    http://yoursite.com/streaming/file.mp3

    MediaElement will determine the opened stream type as mp3 but real data will came from recit.aspx.

    It's just an example; your implementation may differ. But I hope you've got my point.
    2
    It exists guys, I did It

    Hello guys,

    Stop looking for a grooveshark app, i did this app 2 month ago !! (lucky you)

    But hold your horses there's one major problem with my app and the current WP7 developpement kit.

    I actually made 2 versions of the app and was about to do a third one.

    The first one was using a media element and the URL rewriting trick discussed on page 2, but this solution is using my personnal server so I can't make it public cause it's very slow, so I'm only using it for my personal usage. (If someone has a strong server that could host it, i could release this version).

    The second solution is using a MediaStreamSource for buffering and playing music in the media element, but the current version in the developpement kit, is not well implemented, so the app don't behave very good. (This solution allowed me to be totally independant of my personnal server and request directly the grooveshark servers).

    To get a good behavior with this solution and the actual developpement kit I had to totally download the music befor starting to play it (wich is not satisfying to me).

    So the third solution (I was about to developpe) just download entirely the song before playing it. But this third solution has a great advantage, because the music can be played directly in zune, and don't need the app to be open once the music is downloaded.

    So guy just tell me, cause I don't mind sharing my code but I think I should release just one version.

    And sorry for my english, I'm French !!
    1
    Would it be possible with the current Marketplace restrictions to develop a streaming client for Grooveshark?

    Nanogroove and GrooveFish did that on Windows Mobile, it would be great to have such a client on Windows Phone 7, i would definitely pay for such an app.

    Also there is a thread going on, on the official Grooveshark forums but there is no official answer till now.
    The official clients on iPhone and Android are coded really well and add a great value to the platform.

    If you like Grooveshark help us put some pressure on them :D

    http://forums.grooveshark.com/discussion/1262/Grooveshark-on-Windows-Phone-7
    1
    I can suggest a little tricky solution (I've used to "hack" Google's TTS API). Yes, MediaElement can't play mp3 stream not ended by extension ".mp3". Not sophisticated design of course...
    But you may create and use an URL redirector! You just need your own site running Apache with URL rewrite module installed.

    Create directory, for example, "stream" and create inside a file ".htaccess" with content:


    So, you should use the following url for ME Source property:
    http://yoursite.com/streaming/file.mp3

    MediaElement will determine the opened stream type as mp3 but real data will came from recit.aspx.

    It's just an example; your implementation may differ. But I hope you've got my point.

    Hey, thank you! It actually did the trick. In a day or two I'll try to release fully working player.