Welcome to MSDN Blogs Sign in | Join | Help

Demo Live Streams in Silverlight

Customers that I demonstrate Silverlight to, often ask me about Live Streaming using Silverlight. It is actually pretty trivial to demo a live stream.

To create the live source, all you need is a digital video camera that plugs into either a USB port or the 1394 port on your laptop. Your standard DV Handycam is fine(I have tried my Sony Mini DV successfully) , and so are any of the typical clip-on style video conferencing cameras (like a Microsoft Lifecam). Obviously this provides an SD source – to get HD you will probably have to shell out some more money and get one of the new fangled HD consumer cameras.

You will also need an encoder (either Expression Media Encoder or Windows Media Encoder works fine) and a MediaElement on a page pointing to the URL where the encoder publishes the stream. If you want to get fancy and demonstrate a somewhat more realistic scenario, you can also add Windows Media Services as the streaming service to this mix – I typically use Windows Media Services 2008 running in a VM.

Once you plug in the camera and switch to Live Streaming mode in your encoder, xMedia Encoder or WM Encoder will pick up the camera as both a video and an audio source. Below is a snapshot of xMedia Encoder using my Lifecam as a source.

image

The default publishing options for xMedia Encoder is to broadcast over port 8080 - make sure you check the Streaming checkbox in the Output tab.

image

Your MediaElement declaration can look like so:

<MediaElement x:Name="MediaElem" Source="mms://localhost:8080/" AutoPlay="true" Width="800" Height="600" Stretch="Fill"/>

And below is the result - my handsome mug in all its glory :-).

image

If you want to make the scenario a little bit more realistic, you may want to add a streaming service to the mix. It is highly unlikely that a production environment would allow players to directly connect to an encoder.

I have been pretty successfully using  Windows Media Services 2008 on a Windows Server 2008 Enterprise RC0 VM. Once you install Media Services, you will need to add the Streaming Media Server role to the server instance. You will then need to take the following steps to set up Windows Media Server to stream your live content:

  • Enable the HTTP Control Protocol on the Media Server. To do that open up the MMC snap-in for the Media Server, navigate to the root node (should be the name of your server), and the Properties tab within. Select the Control Protocol category, select the "WMS HTTP Server Control Protocol" plug-in, and right click "Properties".  If you are also running IIS on the same box, make sure to select some other port (other than 80) in the property page.

image

  • Bring up the "Add Publishing Point (Advanced)" wizard (right click on the Publishing Points node), and create a Broadcast pub point, and specify "push:*" as the content location. This allows the encoder to push content to the pub point, and activates the pub point automatically once the encoder starts pushing.

image

Once you are done, revisit Expression Media Encoder, and change the Streaming settings in the Output tab to publish to the publishing point you just set up, by providing the URL to the publishing point. The URL is of the format http://[Media Server Name]:[Port You Selected]/[Publishing Point Name]. Clicking the Pre Connect button will confirm connection, and may ask for credentials depending on your domain settings. With this out of the way, if you start Encoding, the stream will automatically be pushed to the Publishing Point by Expression Media Encoder.

image

Your MediaElement declaration can look like so:

<MediaElement x:Name="MediaElem" Source="mms://svr08-mediasvr:49000/SLLiveStream" AutoPlay="true" Width="320" Height="240" Stretch="Fill"/>

And that's all you need to do to get Windows Media Server into the streaming process.

Published Friday, November 30, 2007 2:12 PM by jitghosh

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Free People Searches &raquo; Demo Live Streams in Silverlight

Friday, November 30, 2007 4:13 PM by Free People Searches » Demo Live Streams in Silverlight

# re: Demo Live Streams in Silverlight

Every little bit helps - thanks (and keep them coming)!

Monday, December 03, 2007 5:40 AM by Amy

# re: Demo Live Streams in Silverlight

Can someone remotely access the media stream with an IP address and the port number?  Or do you have to use Media Server step that you describe above?

Dave

Thursday, January 10, 2008 8:13 AM by dave in tokyo

# re: Demo Live Streams in Silverlight

Yes you can. Whether you choose to use WMS for setting up the streaming backend or not, as long as the stream is available over one of the compliant protocols i.e. http, rtsp or mms Silverlight should be able to access and play the stream.

Thursday, January 10, 2008 8:50 AM by jitghosh

# re: Demo Live Streams in Silverlight

This article is very Useful, may I have your email address to know more about live stream with silverlight? Thanks.

Saturday, February 02, 2008 12:33 PM by Melvin Ng

# re: Demo Live Streams in Silverlight

i am not able to connect to my media server by using your format. is there any alternate

Wednesday, February 27, 2008 6:28 AM by Magesh

# Can Silverlight Authenticate Against WMS Streams?

Great post. Right now I'm using Windows Media Services to expose a collection of music. I'm using authentication to protect the media. When I point Silverlight (2 Beta 1) at a protected URI, I get an error. Is there a way to authenticate against a WMS audio/video resource as I do when I point Windows Media Player or Realplayer at it?

Friday, April 04, 2008 5:11 AM by Andy Clingman

# Multiple Source

Very helpful information, thanks! How would you go about adding a second video camera source, can you switch between the two with Windows Media Services or do you need additional software/hardware?

Saturday, May 24, 2008 1:57 PM by justazealot

# re: Demo Live Streams in Silverlight

Thank you so much. Your post helped me. I've been trying to stream a live source from WMS and couldn't. But I finally can!

Tuesday, May 26, 2009 1:52 AM by mrprata

# re: Demo Live Streams in Silverlight

Hi,

I am new to this live streaming. So i dont underlstand completely. Can you send me somthing that may be useful.

this is my mail id : shanvm@in.com

Wednesday, May 27, 2009 6:31 AM by shan

# re: Demo Live Streams in Silverlight

Hi,

Thank you for the nice article!

Can you please specify where can we find "MMC snap-in for the Media Server".

Thanks

Friday, June 19, 2009 10:42 AM by Nikolay Raychev

# re: Demo Live Streams in Silverlight

Good information. Currentrly iam working on Smooth Streaming. How to do Live Smooth Streaming using Expression Encoder 3. Could you throw some information on how to generate Live MBR to Media server from Expression Encoder 3. My Mail ID : prasaddamgeti@gmail.com

Saturday, October 03, 2009 3:36 AM by Durga Prasad

# re: Demo Live Streams in Silverlight

I cannot do the same with encoder 2 sp1 and also encoder 3. Its always "Couldnot open media file mms://127.0.0.1:8080/ AG_E_NETWORK_ERROR". Should I try to change some setting in encoder as well as IIS 7 on Vista?

Thanks

Saturday, October 03, 2009 7:13 AM by Tue

# re: Demo Live Streams in Silverlight

Is there any way to remove latency thru Expression Encoder into silverlight?  I only need one person in the world at any given time to view the stream from an IP camera so bandwidth is not an issue?  Any thoughts on how this could be achieved?

Tuesday, November 03, 2009 1:00 PM by Eric Wilson

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker