This post is walkthrough on enabling smooth streaming of media over IIS and then stream over Silverlight client. There are very good documentation available on IIS official site to have a better understanding of smooth streaming. So I am not touching theoretical concept behind smooth streaming in this post. However I have shown steps by steps to enable smooth streaming of media over IIS then to stream over Silvelight client.

See smooth streaming video below ,

Essentially there are four majors steps you need to do

  1. Enable Smooth Streaming on IIS
  2. Encode Media File
  3. Publish Encoded file over IIS
  4. Streaming over Silverlight

Enable Smooth streaming on IIS

You need to download and install IIS Media Services. Go to below URL to download and install IIS Media Services.

http://www.iis.net/download/SmoothStreaming

image

After successful installation, you will have a section of Media Services in IIS.

image

Encode Media File

To encode media for IIS smooth streaming you need Microsoft Expression Encoder 4.0 pro. If you don’t have installed that then download and install that. It comes as part of Microsoft Expression.

Step 1

Very first open Microsoft Encoder Pro 4.0. You will get prompted to choose Project type to be loaded. Select Silverlight Project and press Ok.

image

Step 2

In this step you need to choose the media file to be encoded and streamed over IIS. Click on File in menu and select Import.

clip_image001

Choose media file to be encoded and streamed.

clip_image003

Step 3

In right side tab select Preset option. If you are unable to find Preset tab, select windows from menu and check preset.

clip_image004

From Preset tab select Encoding for Silverlight and then select IIS Smooth Streaming. After selecting option of IIS Smooth Streaming, you can choose VBR rate of your choice.

clip_image005

clip_image006

After IIS Smooth streaming type doesn’t forget to click Apply button.

Step 4

There are many options available for you to configure like,

  1. Thumbnails
  2. Security
  3. Template options
  4. Output path
  5. Publish etc

You can set values for above options as per your requirement. I am going to set output path here. Make sure you have created a folder on your local derive to set as output path for the encoded media for the streaming. On my local D drive, I have created a folder called StreamDemo. So set the output path as below

clip_image001[5]

Make sure to check Sub-folder by job ID. Leave Media File name as default name.

Step 5

If you have set the values for everything required then go ahead and click on the Encode button in the bottom.

clip_image002

You should be getting Encoding status message as below.

clip_image003

After successful encoding you will get encoded media playing the browser from the local derive. Now you have encoded media file.

Publish Encoded File over IIS

To stream over IIS, you need to publish encoded media over IIS. Process to publish encoded media is same as publishing any other web site over IIS.

Step 1

Open IIS as administrator and add a new web site

clip_image001[7]

Step 2

In dialog box you need to provide below information

  1. Site name: Give any name of your choice
  2. Port : Choose any available port above 1024
  3. Host Name : Leave it empty
  4. Type : Http
  5. Check the check box start web site immediately.

In Physical path, give the same location Encoded file is saved. In previous step while encoding media for streaming, I save file in location D:\StreamDEmo. So I am going to set Physical Path as D:\StreamDEmo.

clip_image002[5]

Click Ok to create web site in IIS. So we created site StreamingMediaDemo1. Right click on that and select Manage Web Site and then Browse.

clip_image003[5]

On browsing most likely you will get forbidden error message as below,

clip_image005

Append Default.html in URL to play the media.

clip_image006[5]

Media will be played as below,

clip_image007

Now append wildlife.ism/manifest to the URL. This manifest file would be used in Silverlight and other clients to stream media over IIS.

clip_image008

Note: In further post; I will discuss more theory of streaming manifest file.

See Video of above performed steps below ,

Streaming over Silverlight

To Play media on Silverlight download below player from the CodePlex.

http://smf.codeplex.com/releases/view/63434#DownloadId=222617

After download extract the file on locally. You will have to add references of these dll in Silverlight project. Since dll got downloaded from the web, so they would be locked. To use them in the project right click and unblock them.

Step 1

Create a Silverlight project.

clip_image010

Choose the Host application and select the version as Silverlight 4.0

clip_image011

Step 2

Right click and add the reference from the extracted file of pervious step.

clip_image002

The above are DLL of the media player you downloaded from Codeplex.

Step 3

You need to download IIS smooth client and install from below URL.

http://www.iis.net/download/smoothclient

Step 4

Right click on Silverlight project and add reference of Microsoft.web.media.smoothstreaming.dll

To locate this file on your local drive browse to C:\Program Files (x86)\Microsoft SDKs\IIS Smooth Streaming Client\v1.5\Silverlight on 64 bit machine.

clip_image004

Step 5

Next we need to design Silverlight page. Open MainPage.xaml and add namespace,

clip_image006

And add a player on the page downloaded to play stream media as below,

clip_image007[6]

Eventually xaml will be as below with a textblock to display message and player

Mainpage.xaml

</span>
<pre><UserControl x:Class="SilverlightStreaming.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:strmmedia="http://schemas.microsoft.com/smf/2010/xaml/player"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel Orientation="Vertical">
            <TextBlock Text="Streaming Media from IIS on Silverlight" Height="22" Width="266" FontSize="12" Foreground="Blue"/>
            <strmmedia:SMFPlayer Name="strmPlayer"
                                 HorizontalAlignment="Stretch"
                                 Margin="0"
                                 VerticalAlignment="Stretch"
                                 Height="261" Width="395"/>
        </StackPanel>
    </Grid>
</UserControl>

Step 6

We need to write some code on page load to create play list of streamed media and play in the player.

See Video of above performed steps below ,

Mainpage.xaml .cs


using System;
using System.Windows.Controls;
using Microsoft.SilverlightMediaFramework.Core.Media;

namespace SilverlightStreaming
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            PlaylistItem item = new PlaylistItem();
            item.MediaSource = new Uri("http://dhananjay-pc:7654/wildlife.ism/manifest");
            item.DeliveryMethod = Microsoft.SilverlightMediaFramework.Plugins.Primitives.DeliveryMethods.AdaptiveStreaming;
            strmPlayer.Playlist.Add(item);
            strmPlayer.Play();
        }
    }
}

Step 7

Before pressing F5 to run application make sure you have put a ClientAccessPolicy.xml file in D:\StreamdMedia location or the Physical path of IIS website streaming the media to avoid cross domain problem.

Press F5 to run the application.

clip_image001[9]

These were what all required to smooth stream media from IIS and play in Silverlight client. I hope this post was useful. I am looking very forward for your comments on the post. Thanks for reading  Smile



**************

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Advertisements

8 thoughts on “Smooth Streaming in Silverlight

  1. I followed the all steps to create a publishing point and connect to it from Expression Encoder 4. It runs perfectly on local pc where IIS 7.0 is running. When I access my live smooth streaming page from another LAN PC, I’m able to view the silverlight player but not showing live streaming and shows an error which is ” can not open media file /live.isml/manifest. Requires output to be hosted on web server running IIS 7.0 with smooth streaming handlerinstalled and silverlight template that supports Smooth Streaming.
    3222 An error has occured.”

  2. Hi 😉

    I am fresh user .. I have already followed this tutorial.. I can’t go througth step 7 !
    “Before pressing F5 to run application make sure you have put a ClientAccessPolicy.xml file in D:\StreamdMedia location or the Physical path of IIS website streaming the media to avoid cross domain problem.”
    Where I could find ClientAccessPolicy.xml ? I don’t know what I should do.
    I can’t received smoothstreaming video…
    I received a player but It doesn’t work..

    I would appreciate for any help please.

    agatte 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s