Silverlight + WCF Video Streaming

Enill
Enill used Ask the Experts™
on
Hi,
i am in need of a concrete example(can be a project, solution, some code example, etc...) of streaming a video to a Silverlight Player from a WCF Service hosted in IIS.

What i want to do: I have some videos on a remote server that i would like to play in a silverlight application. The user need to be able to play, stop, pause it of course. And both the server and silverlight can't load the whole video in memory(the videos are really big) thats why i want to stream(or buffer?) it.

actually i was able to get a stream from my wcf service and play a small video of 4.0mb. It was pretty fast since i am testing in local.

However, when i try to stream a 300mb videos, it look like my silverligth client is trying to totally load it in memory or something and then play it.

Result: My IE is taking well over 1gb of memory and crash with outofmemoryexception.

This is a IIS hosted WCF Service.

My web.config configuration is:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="testPJ.testPJVP.customBinding0" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
          <security mode="None"></security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="testPJ.testPJVP">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="testPJ.testPJVP.customBinding0" contract="testPJ.testPJVP" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>

Open in new window


My WCF method look like:
[OperationContract]
        [WebGet(UriTemplate = "media/{name}")]
        public Stream getVideo()
        {
            if (File.Exists(@"c:\test.wmv"))
            {
                return File.OpenRead(@"c:\test.wmv");
            }

            return null;
        }

Open in new window


*** Even if i told my wcf method to return a Stream, i get a byte[] on the client side.

My silverlight client:
ServiceReference1.testPJClient zc = new ServiceReference1.testPJClient();
            zc.getVideoAsync();

            zc.getVideoCompleted += (s, e) =>
            {
                Stream st = new MemoryStream(e.Result);

                mePlayer.SetSource(st);
                mePlayer.Play();
            };

Open in new window


Note: This application will need to support over 100-1000 users at the same time. This is why i am trying to do streaming.

Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial