I’ve been working a lot more from my home office lately and it was getting increasingly challenging during this summer with both kids at home.  Okay, let’s be honest, my wife was probably more the distraction :-).  When we built our home 4 years ago we were both working from home and built an office specifically for the both of us.  3 dedicated power circuits to the room, hard-wired ethernet to that room x 4, wireless printing, split desks, tile floor, etc., etc. – everything I wanted in my office for convenience.

Fast-forward 4 years.  Add 2 kids.  Add wife who isn’t working anymore, but maintains a full-time job managing the local community stuff she’s involved in and of course, our family…which she does a fantastic job at I might add!  It was just getting too difficult for me.  I’ve been relegated to the basement back bedroom.  I didn’t want to work in our basement because there were no geek creature comforts and where I put the wireless wasn’t ideal for the room where I would work anyway (hindsight is 20/20 right?).  Well, I couldn’t fight it anymore.  One trip to Ikea to get a desk add-on to a piece of furniture she already had in her scrapbook/activity room and I had a desk (and a new chair).  It hasn’t been the best.  The lighting sucks and it isn’t as comfortable peripherally speaking as my designed office for me.  Recently I’ve anticipated adding more network stuff (NAS, VOIP device, etc.).  The wireless only solution wasn’t going to cut it for me.

Netgear Powerline HD KitAs such I never expected to be down there, I never wired for anything beyond the one port for the wireless access point.  I had a cabling guy stop by last night to talk with me about my options.  I didn’t like the 15-20 drywall hole option too much and said I’d think about it.  I remembered seeing something about ethernet over power lines.  I did some research and found the HomePlug Alliance which provided some good general information for me.  Enough to convince me that it wasn’t something I should just disregard as an option.  Today I went to Fry’s Electronics to peruse my options.  There were many.  From manufacturers I didn’t know to those that you recognize: Netgear, D-Link, Linksys, etc.  I didn’t really seek out any advice in the beginning on what would be best, so I fell into the marketing scheme – bigger numbers is better right?  So I bypassed the 14MBPS, skipped over the 85MBPS, and opted for the 200MPBS (I couldn’t find any higher).  I purchased the Netgear Powerline HD Network Kit.  It was on sale as well which made it more attractive (picked it up for $110).  I was skeptical but figured I had nothing to lose.  $110 or hundreds more in cabling and drywall repair jobs.  The kit comes with two adapters.  Plug one into an outlet, connect it to your router and plug the other where you need ethernet connectivity.  I did just that.

I’m happy to report I don’t notice anything different…which is to be expected.  It literally did “just work” for me.  I went to no configuration screens, installed no software, etc.  One blue light lit up on one box…a few seconds later the other blue light on the other box was blinking indicating they’ve found each other.  Happy times.  My speedtest.net rating showed the same speeds I expected to get and I don’t experience any noticeable lag between requests or anything.  I haven’t noticed anything in my home network going awry at all either.  My XBOX just died, but I think that is more of a coincidence than a side effect.  If it turns out it isn’t I’ll report back.

Anyhow, a cheap alternative to wiring.  Sure if you want fiber or gigabit connections, this isn’t going to work.  But for the average joe, the older home, etc. – so far it is turning out to be a simple alternative that works.  Simple to set up too which always is a plus.

This week I had the privilege of attending and helping with some Silverlight in casual games presentations at the XNA Gamefest conference happening in Seattle.  I say helping because the real game experts were there.

Two Silverlight presentations were given.  One by Bill Reiss/Joel Neubeck and the other by Mike Snow.  Between the two sessions we covered concepts in Silverlight game development as well as a walk-through of starting out to create a simple game.  I consider these guys to be the foremost experts on the topic given their experience in creating games like Dr. Popper, Stack Attack, Zero Gravity, Zombomatic and Tunnel Trouble.  Mike also will be posting some game frameworks as well as demonstrating some multi-player aspects.

It was a decent turnout for those interested in learning where Silverlight plays in casual games.  We also were able to talk with the MSN Games teams that gave us an understanding of what would be needed to implement a game in Silverlight.  I was surprised to see how simple the initial process is to get a game in the pipeline for consideration of MSN Games.  So if you have some thoughts on writing a game in Silverlight and want a distribution channel…consider MSN Games!

Silverlight Game Contest!

Need some incentive?  How about a Silverlight game contest?  TeamZone Sports is sponsoring a contest…with some cash prizes.  Official rules are coming soon, but you can sign up to be notified here.  I’m excited to see what comes out of the contest!

XNA and Silverlight?

With the announcement at XNA that the XNA Community games are going to be opened up wider so that anyone can essentially write an XBOX game and have other community members consume it, I suspect people will be jumping at those opportunities!  Maybe you want a game in multiple channels: XBOX, Windows, Zune, Web.  There are going to be things you may want to know in advance.  Bill did a demonstration of a single code base that ran on Windows (XNA), Zune (XNA for Zune) and Silverlight.  It was pretty cool to see the same experience in all those different platforms.  Bill had some good advice on things to look for when developing for this goal…maybe he’ll append those to the post (hint, hint).  You can download his sample code here.

Thanks to MSN Casual Games for inviting Silverlight to the conference (and for the sweet swag).  Thanks to Bill and Joel as our MVPs in this area for representing their experiences and sharing their knowledge with us.  Thanks to Mike for sharing his expertise and be on the lookout for him to provide some source on how he accomplished some multi-player game play within Silverlight using sockets. 

One of the things that makes Silverlight 2 great is the ability to create a very flexible framework application that others can use and can be embeddable with some dynamic properties.  This is the method used in the SL2 Video Player to provide a completely dynamic player that is portable.

How?  Using the initParams property of the plugin.  There are a few ways you can do this.  I’ve just uploaded a video demonstrating three of them:

    • Creating App Resources
    • Passing into the root visual constructor
    • Using URI query string parameters

What?  Query string params?  Yep, the HTML bridge gives us a nice object model actually to inspect those parameters too.  Take a look at the latest video on the Silverlight community site!

In IIS7 you can do very simple testing for SSL related site hosting.  It literally is like a 2 click process:

Enter a name for the cert and done, you now have SSL on your box.  Of course this is a self-issued/signed certificate so it will do you know good in the real world, but for most of the developer world it will work fine.  There may be those times, however, where things may not be quite working right and you want to eliminate the self-signed cert form the equation to make sure it isn’t the issue.

This was the need in my case.  I’ve been doing some messing around with secure services and Silverlight scenarios and ran into one issue that I needed to eliminate the self-signed cert and get a ‘real’ one.  Self-signed certs have a quirky behavior in browsers and I just wanted to eliminate that in my test.

I shouted out on Twitter an ask of “cheap ssl providers?” and got a few responses:

I always forget about GoDaddy when it comes to anything but domain registrations but they do have a lot of other services and this reminded me that they do have a good price on SSL certs ($30/year).  Having had previous experience (and happy with) InstantSSL I knew of their offering as well.  My goal was not to secure a beefy e-commerce system, or help secure personal information, etc.  I needed “https:” and that little icon :-) -- that’s it.  So for me, low cost was what I was seeking – I had no need for any of the deluxe offerings.

With that in mind I didn’t want to purchase a cert from each on of these just to see what the deal was.  That being said, this isn’t all too fair of a comparison of them all, but only 2.  Please keep that in mind.  GeoTrust was by far the most expensive and I can’t quite tell why to be honest.  RapidSSL was pretty on par with everyone else.  OpenSSL.  Well, it’s free if your time is.  I mean it isn’t necessarily integrated into every server environment (yes I know it likely is in Linux), so be aware that there is some setup there.  Remember my goal: fast and cheap.

GoDaddy was offering $15/year SSL certs and InstantSSL had 90-day free ones.  Both perfect for my needs.  I didn’t find out about GoDaddy’s deal until after I started down the path of InstantSSL (which you’ll see was quick).  GoDaddy’s $30 price tag for my purposes was enough for me to consider just doing the free 90-day one from InstantSSL. 

Both processes would require me to create a request from my server.  I’m taking that part out of the equation.  The time I’m talking about is from request to issuer to installation and operational. 

IntantSSL had a simple form.  I input my CSR text added my contact information and clicked submit. 

I was told I’d get two emails: one verifying me as the domain owner (pulling contact information from WHOIS…another reason to ensure you always keep this updated correctly) and once complete a second one with my cert.  By the time I was done reading that sentence, the verification email was in my inbox.  Click on a link, cut/paste a code, click submit.  Inbox now contained my cert and instructions.  Installation was a breeze as i just processed the request and pointed the file.  Seriously, the total time was < 8 minutes.  2 emails, one click.  Having been a previous customer I can assure you that the process is the same should I have opted for their 1 year basic SSL at $80.  Just as quick (adding the purchase step in).

In that time I saw a twitter that GoDaddy had a $15 deal promotion.  I figured, what the heck, that price removed any barrier for even my test use of the cert.  So I started their process.  It went something like this:

    1. Buy cert, add to cart
    2. Go through 3 screens of add-on service (clicking ‘no thanks’ each time)
    3. Checking out (fast/simple)
    4. Received email – instructions weren’t too clear on next step
    5. Logged into account
    6. Navigate to certificates…realized i bought a “credit”
    7. Activate “credit”
    8. Go to cert manager
    9. Enter request
    10. Wait for verification
    11. Recieve certs.

It still didn’t take very long, but was noticeably more steps and not clear direction for a lay person I’d have to say.  I received the cert in my email with a link to instructions.  I was warned of this on Twitter that there would be an extra step.  It isn’t that bad, but is an extra step.  GoDaddy needs some intermediate authorities to be on the box before your certificate is trusted.  They ship these with your cert so you don’t have to go digging.  This step does involve opening Management Console, etc.  and then going to finalize the request in the IIS manager.  Overall time for GoDaddy – I’d estimate 15-20 minutes.  Still not bad…and the price is right.

I’ll stick with my GoDaddy cert of course because at the $15 price I got a full year so no reason to change now.  I would have to say that GoDaddy and InstantSSL both offered the easiest and fastest route to request –> operational I could have hoped for in the process.  I imagine by the name ‘RapidSSL’ that they’d be similar.

One Twitter comment was:

instantssl is actually the best quality for the price I've seen.

And having seen their offerings and been through their process, I’d have to agree.  Either way there is a list of folks to look at.  I’d recommend InstantSSL first, then GoDaddy based on my experiences.

Oh yeah, OpenSSL is free…if someone can convince me that I could have set it up in < 10 minutes I would have tried.  It took me longer than that to figure out what I might even have to do!

Now that the Silverlight 2 Video Player is available from Codeplex, I wanted to make it a template for Expression Encoder.  I’ll attempt to articulate the steps below.  It’s actually pretty trivial.  In fact in the current incarnation, you have to throw some extra stuff in there you may not need :-).

Step 1 – Creating the template folder

While I’ve covered this in previous posts and this is also well documented in the Encoder SDK documentation.

First you’ll navigate to C:\Program Files\Microsoft Expression\Encoder 2\Templates\en and you’ll see the existing template folders.  The folders do not represent the name of the template in the Encoder UI, so don’t worry about that.  Create a folder here.  I called mine SL2VideoPlayer.

Step 2 – Creating the hosting page

Go into that folder and we’ll start creating some files here.  We’ll need the XAP from our media player (in my case VideoPlayer.xap) and simply place it in here.  We’ll also want to put a snapshot of our player here.  You can really name it to be anything, but I’m a fan of consistency and other templates call it preview.jpg so I stuck with that.  I recommend a proportionate image size.  You’ll notice the other templates don’t have this image anymore in Encoder 2.  That’s because their preview actually renders the player in Silverlight.  I’ll be honest here and tell you I haven’t messed around enough to know how to enable that, but my static preview image works and I’m sticking with that as it serves its purpose.

The main file we’ll need here is a hosting page.  I’ve called mine default.html again for consistency.  It is here where we have the magic happen.  In fact this step bleeds into the next 2 steps.  For now, you’ll want to create your hosting page that will host the Silverlight player.  This can be basic or elaborate…just create one.  In the next step we’ll make it wake up.

For me I just took the test page format provided to me by Visual Studio 2008 and the Silverlight project template.

Step 3 – Creating parameters for Encoder

Having a static page is nice, but doesn’t really help Encoder understand what we mean.  To our hosting page let’s add some parameters.  Encoder’s build process understands a certain set of parameters that are helpful for us.  It isn’t the intention of this post to emit them all to you, that’s what the SDK is for, but I’ll point out some key ones.  Let’s take a look at the ‘header’ of our hosting page:

   1: <!-- <$@ Options LaunchPage="true"$> -->
   2: <!-- <$@ Options Name="Silverlight 2 Video Player"$> -->
   3: <!-- <$@ Options TemplatePreviewImage="preview.JPG"$> -->

These are the first 3 lines of my default.html page.  They should be pretty self explanatory.  You can see now where the Encoder UI gets the template name from.  The next few lines immediately after this are interesting.  Here’s what my template looks like (after the first 3 lines above):

   1: <!-- <$@ Parameter Name="AutoPlay" Caption="Automatically start video when cued" Tooltip="Select to begin playback when video is loaded" Type="System.Boolean" Default="False" $> -->
   2: <!-- <$@ Parameter Name="EnableCaptions" Caption="Allow closed captions to show" Tooltip="Select to allow closed caption text over video during playback"Type="System.Boolean" Default="False" $> -->
   3: <!-- <$@ Parameter Name="Muted" Caption="Mute player on start" Tooltip="Select to begin playback in a muted state" Type="System.Boolean" Default="False" $> -->
   4: <!-- <$@ Parameter Name="MediaMarkers" Caption="Enable Media Marker Animations" Tooltip="Select to enable animations to appear when media markers are found" Type="System.Boolean" Default="False" $> -->
   5: <!-- <$@ Parameter Name="ScaleMode" Caption="Stretch Mode" Tooltip="Change the way the template is displayed on the page" Type="System.Enum" EnumValues="Profile Size=1,Stretch=2" Default="Profile Size" $> -->

Okay, these may need a bit more understanding.  Let’s dissect one of them a bit as the all are of type parameter.  First the Name – this is what will be known to your code later (in step 4) so this is really an internal name…not visible to the user.  The second attribute, Caption, will be seen to your user and should be descriptive, but concise.  Tooltip is, well, a tooltip…and if you don’t know what that is, maybe you shouldn’t be customizing templates?  Type is the data type of your parameter…these are standard .NET types like System.String, System.Boolean, etc.  The final attribute, Default, is exactly what it sounds like – providing a default value for the parameter.  At this point you may be asking yourself: How is the user providing input to these values? and that would be a great question.

You see, when you add parameters to your template they show up as advanced options to the template.  Let’s look at Encoder 2 after we’ve selected our template.  Notice the template name and then the expander decorator:

If you expand these advanced properties you’ll see your parameters.  Here’s my setup for the SL2VideoPlayer template:

Pretty cool, huh?  You can totally provide your users of your template the option to provide input parameters.  Now my params are pretty obvious but you could probably think of some other creative uses.  But we didn’t have to do anything to get some of this free UI goodness!  Now we have our template selectable and our users can provide certain parameters…let’s see how we can use them.

Step 4 – Reading the parameters in the template

We’ve got the input parameters, how do we use them?  Well for my input parameters, these directly translate to initParams for my Silverlight application.  However regardless there are some other things you can get other than parameters.  Again, I’ll defer to the full Encoder SDK, but since you are encoding a file, I’m guessing at least the output of that file is an important attribute you’ll want to be aware of.  Again, let’s take a look at other code in my default.html template where I use code to get at these parameters:

   1: <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" 
   2:     <$ if (TemplateParameter.ScaleMode == "1") { $>width="<$=PublishedItems[0].MediaItem.VideoSize.Width$>" 
   3:     height="<$=PublishedItems[0].MediaItem.VideoSize.Height$>"<$}else{$>width="100%" height="100%"<$}$>>
   4:         <param name="source" value="VideoPlayer.xap"/>
   5:         <param name="onerror" value="onSilverlightError" />
   6:         <param name="background" value="white" />
   7:         <param name="initParams" value="autostart=<$=TemplateParameter.AutoPlay$>,muted=<$=TemplateParameter.Muted$>,
   8:             captions=<$=TemplateParameter.EnableCaptions$>,markers=<$=TemplateParameter.MediaMarkers$>,
   9:             m=<$=PublishedItems[0].OutputFileName$>" />
  10:         <a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;">
  11:              <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
  12:         </a>
  13: </object>

See some familiar code here?  the “<$>” decoration is instructing the Encoder build process that this is code to be executed.  What kind of code?  .NET baby.  My example is very, very simple here and in fact I’m just extracting attributes.  The SDK has examples of more advanced techniques should you need them.

You can see the use of TemplateParameter that enables me to get at the parameter configuration options that we’ve provided to the user.  I just retrieve them, can inspect them, etc.  Some of them I’m just passing in the parameter, others I’m acting upon.

The one thing that you’ll want to familiarize yourself with is the PublishedItems model.  This represents the Encoder job activities.  You can see that my reference actually uses an index of 0.  This is because Encoder supports encoding multiple files at once and your output could contain more than one file.  This could be helpful in creating a template that uses multiple media sources and you are creating a visual playlist feature.  For me, I’m just using one, so I grab the first item.  I can then reflect on properties of that published item such as name, video size of the media, etc.  A very helpful and powerful little scripting-looking language that can be leveraged to really customize your template.

Using this code we now have our default.html file that in the end will be complete and have all our HTML provided for us.  I should note that the attributes in the header of the page will not be emitted.

Step 5 – Additional File(s)

What is really cool is that the process looks at other files in your template to see if they need to be acted upon as well.  So if you have javascript or other files that might need to be dynamic based on output, you can use the same coding methods as above in other files – it doesn’t all have to live in default.html at all!

Step 6 – Prepare the template for Silverlight Streaming

At this point our template will work.  We can import a video media asset, choose our template and click Encode.  After encoding the start page will launch with our options passed in and render.  But what about the next step?  What if I wanted to upload to Silverlight Streaming Services to host my media and application.  Well, I know that there is already a plugin that allows a quick upload for this – the SLSPlugin.  How can we tap into this?  I thought that I’d be able to just click publish and it would work, but that isn’t the case.

First the plugin expects at least one XAML file to exist…and we have a XAP.  So trick one, create foo.xaml with nothing in it and put it in the template folder.  Done.

Second, it expects a manifest.xml file to exist.  This is because the plugin is packaging our template assets into a ZIP that Silverlight Streaming understands for multiple assets.  This requires a manifest definition file that is a part of that ZIP.  So I create a manifest.xml file and put it in my template directory.  Remember step 5?  In my manifest I have it with some code as well:

   1: <SilverlightApp>
   2:   <source>VideoPlayer.xap</source>
   3:   <version>2.0</version>
   4:   <name><$=PublishedItems[0].MediaItem.Name$></name>
   5:     <$if (TemplateParameter.ScaleMode == "1") {$>
   6:         <width><$=PublishedItems[0].MediaItem.VideoSize.Width$></width>
   7:         <height><$=PublishedItems[0].MediaItem.VideoSize.Height$></height>
   8:     <$}$>
   9: </SilverlightApp>

So my manfiest is dynamically generated based on the output as well.  This file is created as a part of the encode process and is not a part of the default.html file…so you can see an example of separate files being able to access the parameters as well as the PublishedItems collection as well.  Now that the file is created it can get packaged into the app!

However, with my implementation of SL2 Video Player I run into a snag.  You see the default.html page is great and we can use it and it supplies all of our needs because we are using initParams.  However SLS doesn’t use our hosting page.  It generates it’s own HTML hosting page and creates the Silverlight object using createObject.  This is fine except for one thing: it doesn’t currently support initParams.  Yes I know createObject does, but SLS hasn’t built in the support to use those yet.  So alas, my final step here for my particular use is broken :-(.  I’m working with the SLS guys to implement initParams support much easier.  I’d love to see it a part of the manfiest options so I could have:

   1: <SilverlightApp>
   2:     <source>VideoPlayer.xap</source>
   3:     <initParams>m=foo.wmv,captions=true</initParams>
   4: </SilverlightApp>

And then the solution would be complete and life would be glorious.  We’ll let you know when that happens.

Summary

In brief summary hopefully this let’s you see some of the options you have for still being able to use Silverlight 2 in your Encoder 2 workflow.  The SDK provides a way for us to get integrated into the encoding pipeline and do our customizations.  It’s simple to do and will only get better.  You can download my complete template example here.  Please note that this was based on an earlier build of the SL2 Video Player.  The project has been progressing and you can get the latest version of the player at the Codeplex project site.