Streaming server c#

From: Mikee29 May 2010 15:02
To: ALL1 of 1

Hello.

 

C#/.NET question!

 

I'm in the middle of writing the new version of my office jukebox - this one uses last.fm's radio API.

 

Currently we have a server machine running the last.fm API, connecting to last.fm and then playing the music using WMPLib (on the server machine). I'm streaming track updates and other information to the client browsers using HTML5 websocket (and if the browser doesn't support it, it falls back to polling the server with soap requests to get the same information).

 

Anyway, a slight problem. I wanted to be able to offer the music stream down the browser if the user wants it - so if they're not in the same room as the server machine they can still listen to the radio stream.

 

At first I thought this would be easy, because I could just send down the path to the currently playing mp3 (from the last fm servers) and hook the <audio> tag up to that - but last fm's api only lets you request an mp3 once (which the server is already doing).

 

So...

 

I think I need to start streaming the mp3 from the last fm servers down to web server that's hosting the jukebox web app, then somehow allow the client machines to hook into that stream while it's still being written to.

 

Is something like that going to be possible?

 

I've tried writing the stream to an mp3 file on the web server and serving it down to the browser while it's still being written to, but .NET throws an exception.

 

I've also tried pre-caching entire tunes on the server before sending them down to the browsers, but last.fm's servers only allow a REALLY slow download speed (i.e. the same speed as playback), so you have to wait a full 3 minutes before you can start to do anything - which is a bit lame.

 

Any ideas?