| Comments

In my previous post about cross-domain policy files I received some comments about whether or not cross-domain access is allowed on Silverlight Streaming.  I think really this is two questions that I'll try to clarify here.

What is Silverlight Streaming?

For those who don't know, Microsoft provides anyone with an account to "stream" Silverlight applications for free.  We'll give you 10GB of space to put your Silverlight applications.  There are some limitations, which you can read about in the service.  The "streaming" name has confused some.  It isn't only a "where can I put media files" location, but is a service to "stream" your entire Silverlight application.  You can have a media player, or a hello world textbox...no matter.  If you haven't checked it out, sign up.

Does Silverlight Streaming support cross domain calls from Silverlight?

This really has to do with the Silverlight Streaming API.  Silverlight Streaming provides an API to manage your applications.  You can perform various activities on your Silverlight Streaming account through this API such as managing your applications, requesting files, etc.

Now I'm not sure why you would want to access the API from a Silverlight application, but I will say that the in order for this to happen (as noted in my post about cross domain access), the service would have to host a policy file at the end point.  Silverlight Streaming currently does not have that policy file.

Can my application hosted in Silverlight Streaming access cross domain services?

This is what I think the question really is in the comments.  Yes.  Provided that the service you are accessing has a clientaccesspolicy.xml file at the root of the site, then yes it could.  I whipped up a quick DataGrid sample and put it on my Silverlight Streaming account.  This is a Silverlight 2 application (xap) that calls the MSN Video POX service via a WebClient call.  I take the information and bind it to a DataGrid.  So this application below is hosted in Silverlight Streaming, calling a 3rd party service (which has a policy file enabled) and embedded within my blog post here.

I hope that makes it a little clear that yes you can do this with your apps.

How did you get a Silverlight 2 application on Silverlight Streaming?

Very easily.  Just a bit after MIX08, the SLS team added support for Silverlight 2 Beta 1 applications.  You can read about it here, but here is the manifest I used for the application you see above:

<SilverlightApp>
   <version>2.0</version>
   <source>StreamingCrossDomain.xap</source>
</SilverlightApp>

I added that manifest.xml and my StreamingCrossDomain.xap file to a zip, uploaded it to my account and done.

Hope this helps!

| Comments

so what happens when you want to embed in your page?  well if you have absolute control over your site, you may not need to worry as you'll post your silverlight applications as-is.  but what if you want to just output some smaller silverlight applications in specific areas in your site, blog, etc?

enter .  this was announced at mix07 where you get 4gb storage for free.  now, there are some caveats that you should read about -- the 4gb is total storage, but the per-app upload has some limits...so be sure to read...it may not meet every need.  but if it does, you'll have to know some things.

first, the "streaming" has been throwing people off, and i think i understand why.  our techno geek brains are telling us that "streaming" means media files directly.  because of this people have been asking me they thought you'd upload a wmv file or something and the silverlight streaming would provide a player, etc. as the output.  not so.  is enabling you to host/stream the entire silverlight application.  so basically you develop the wicked-cool-super-slick and want somewhere to host it, the xaml files, associated media, etc.  boom, may be a solution to you.

now, you may have your app, go to silverlight.live.com and then say, huh, now what?  well first you should probably take a look at the sdk link (on the left), then on the right there is a link for create application (under the essential links).  there is some important information for you here.  the most important is the creation of a manifest.xml file.  this is describing your application files requires, your manifest, etc.  it will look something like this:

<SilverlightApp>      <source>Scene.xaml</source>      <width>400</width>      <height>50</height>      <jsOrder>          <js>Silverlight.js</js>          <js>Scene.xaml.js</js>          <js>Default.html.js</js>      </jsOrder>  </SilverlightApp>

once you have that, you need to zip all your files up...except certain ones :-) -- like .media, .html, .aspx, .zip (more on this one later).  you'll have a zip file that might look something like this:

once uploaded, then you'll have to follow the silverlight embed directions (a 3 step process -- or 2 if you don't want to create another file).  below i've embedded in this blog post: 

go ahead, click it :-)

the core of the functionality is in the third step the instructions provide you which will look something like this:

function CreateSilverlight() {    Sys.Silverlight.createHostedObjectEx( {      source: "streaming:/217/SimpleButtonClick",      parentElement: SimpleButtonClickWrapper});  }

okay, now for a few gotchas i've found early on.  first, the complexity of your silverlight app may get your frustrated when you upload it.  for example, i've taken an output player from expression media encoder and it didn't exactly work (although i'm still troubleshooting it, i suspect i know some problems).  one of the reasons why is that it uses some createObject funkadelicness when creating the initialization of the event handlers, etc.  because of this you'll have to look at the loadFunction and onLoad parameter nodes of the manifest file.

second, i am assuming that silverlight streaming is leveraging a feature of silverlight that enables you to compress your assets (or perhaps your entire application) in a zip file.  then using items like the downloader, you can download the zip file (which might be considerably smaller and save some bandwidth) and then pull out what you need from the zip.  it is quite cool, and i have a sample in another post (subscribe now, hint hint).  anyhow, where was i?  oh yeah, well .zip files are not allowed to exist within your .zip application...wait, does that make sense?  basically if you are using that mechanism, it might not work in the silverlight streaming scenario...quite frankly it didn't work for me...maybe more to come on that.

so start your silver-engines, and download some tools, build some apps, upload them and host them...giddyup.