Silverlight and Shoutcast! - Web Dev And Stuff
Wednesday, October 01, 2008 3:26 PM djsolid

Silverlight and Shoutcast!

Finally a solution!!!!!!!! How can we stream a shoutcast radio via a Silverlight application?

Well in 6 steps...

1. Open Expression Blend

2. Create a Project

3. Add a media element

4. Add the code below at the cs (or vb) file

public Page()
{
// Required to initialize variables
InitializeComponent();
this.Loaded += new RoutedEventHandler(Page_Loaded);
}

void Page_Loaded(object sender, RoutedEventArgs e)
{
try
{

myElem.Source = new Uri("http://mystation:port/;");
myElem.Play();
}
catch (Exception ex)
{

}
}

5. We put mms instead of http and at the end "/;" without the quotes

6. We hit F5 and listen our radio!!!

Enjoy!

Edit : it works with http really good but i never tried until now... So no need for mms at the beginning of the URL.

Comments

# re: Silverlight and Shoutcast!

Wednesday, October 01, 2008 8:58 AM by DigiMortal

Please use correct error handling because those empty bodied catch clauses are one of the worst practices in error handling I've ever seen. :)

# re: Silverlight and Shoutcast!

Wednesday, October 01, 2008 9:13 AM by djsolid

I agree with you but it is just an example. I think nobody will use it JUST like this ;)

Nevertheless thanks for pointing it!

# re: Silverlight and Shoutcast!

Tuesday, October 28, 2008 1:32 PM by spavkov

Very nice idea, thanks for bringing it into the light!

Slobo

# re: Silverlight and Shoutcast!

Monday, February 16, 2009 12:51 PM by Dennis

i did everything you described  only when i try to build my project in Expression blend 2 i get an error or two :

"Error 1

The name 'myElem' does not exist in the current context"

"Error 2

The name 'myElem' does not exist in the current context"

now is my qeustion i have added in expression blend 2 an media element but do i have to name it  something like "myElem" ? im kinda new to silverlight and trying to learn as much as i can about it.

# re: Silverlight and Shoutcast!

Wednesday, August 26, 2009 8:01 PM by Sid

Dennis,

You need to name the media element as myElem.

# re: Silverlight and Shoutcast!

Sunday, January 24, 2010 8:14 AM by Marc

Doesn't work Ive got three errors.

Fake!

# re: Silverlight and Shoutcast!

Tuesday, June 14, 2011 3:52 PM by zombee81

That's a bit crawl? Calling it fake because you can't get it to work!  I use Shoutcast streams with flash (as3) and the code looks similar to that.  So my guess is it's not far off!

# re: Silverlight and Shoutcast!

Monday, October 24, 2011 2:20 PM by Ersin

This code not work! I think there is support for shoutcast silverlight.

Leave a Comment

(required) 
(required) 
(optional)
(required)