The Open Source Project Spec: With Reference To Me
http://WithReferenceTo.Me
The application that we’ll be developing in the next phase of the HVP will allow the user to record and then look up everything that happened from day to day.
The application that we’ll be developing in the next phase of the HVP will allow the user to record and then look up everything that happened from day to day.
There has been some thrashing about the HyperVideo player. This note is both an update and an invitation for you to participate.
This is a quick update on the next steps for the HyperVideo Project that will touch on the following three sub-projects scheduled to be completed in the next six months:
Update to the web-based project (HVP v2)
Initial “port” of the HVP to Windows Phone 7 (HVP/WP7 v1)
Transmedia inspired WP7 application (HVP/WP7 v2)
The Silverlight HyperVideo project ran full steam from January through the day before Mix, and then went on hiatus while we all recovered, and while I pondered three critical questions:
The Silverlight HyperVideo Player has met with strong support and interest. This mini-tutorial is the first in a series that will walk through the design and delivery of this project.
| This series will pretend that the design existed before we began coding, and will not take you through its evolution over the months between December 2009 and March 2010. In short, this series is a “drop-line” exercise highlighting how the program works with a focus on teasing out general principles of creating mid-sized line of business Silverlight applications. |
If a picture is worth a thousand words, a video must be worth an order of magnitude more. This video, created as part of the HVP sample set, explains the concepts behind the HVP.
I’m a big believer in diving right into the code, but I did want to mention just a few of the design/coding guidelines I imposed on myself when writing this, and we can explore their motivation, implications and outcome as we go:
Overarching message of the code: Silverlight is an application development framework: treat it like one.
The premise of agile programming dove-tails neatly with the approach I’ve been advocating for two decades: get it working and keep it working. I can’t claim any high minded values behind this; it is just what works for me. Worse, it is what I end up doing, even when I’m supposed to be doing design-first. I simply can’t design in a vacuum and I get very tired and crabby when I do try to design in advance because it doesn’t work. It never works because
The old argument was “don’t paint yourself into a corner.” On reflection, what I found was I was always painting myself into corners, but if I only painted for a few minutes before fixing the problem I was a lot better off than if I’d spent all day at it.
I love the term emerging design because it sounds so much better than “figure it out as you go.”
We’ll come back to the most effective technique I know of for making all this work in large complex applications when we talk later about Test Driven Design, but let’s get started. Here is what I know:
One of the premises of “Emerging Design” that I like a lot is this: don’t design anything until you’re going to implement it. Do not say to yourself “I know I’m going to need this, so let me put in all the hooks I’ll need.” Reason: when you predict what you’ll need, you are usually wrong. Work done today does not save you work later, but work not done today may never need to be done at all.
In that spirit, the first thing to do is to create an application that has the Silverlight Media Framework player in it, and get that working in a very simple page.
| I’m going to re-create the source bit by bit, and make that incremental source available with each mini-tutorial (see bottom of this posting) but please understand that these are not the versions that I created the first time. I’ve condensed the process here to facilitate focusing on what matters, and to reduce confusion. You can find all my dead-ends, mistakes and changes of heart enshrined in the source code history here. |
Since adding a SMF is a well documented and short set of steps, I’ll just take my lead from the SMF documentation and create a simple Silverlight Application named HVPT1 (Tutorial 1). That will create two projects: HVPT1 and HVPT1.web. The startup project will be HVPT1.web, the startup page will be HVPT1TestPage.aspx and the first Silverlight page will be in the HVPT1 (client side) project, the file mainpage.xaml
For the SMF to work, we need the four SMF libraries, which can be downloaded from here, as well as the IIS Smooth Streaming Player Development Kit which is available here. The Smooth Streaming Player Development Kit (SSPDK) is unpacked by double clicking on the downloaded .exe. Place all five DLLs (the four from the SMF and the unpacked SSPDK into the same directory.
In HVPT1 add a reference to all the DLLs except SilverlightMediaFramework.data.dll and then replace the header of HVPT1.MainPage.xaml with the following:
<UserControl x:Class="HVPT1.MainPage"
xmlns:p="clr-namespace:Microsoft.SilverlightMediaFramework.Player;assembly=Microsoft.SilverlightMediaFramework.Player"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="640"
d:DesignHeight="480">
Note that the second line declares a namespace alias “p” that refers to the Microsoft.SilvelrightMediaFramework.Player. You can now declare the player and its source, which must be a streaming media file. Here’s the entire .xaml file:
<UserControl x:Class="HVPT1.MainPage"
xmlns:p="clr-namespace:Microsoft.SilverlightMediaFramework.Player;assembly=Microsoft.SilverlightMediaFramework.Player"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="640"
d:DesignHeight="480">
<Grid
x:Name="LayoutRoot">
<p:Player>
<p:CoreSmoothStreamingMediaElement
AutoPlay="True"
SmoothStreamingSource="http://video3.smoothhd.com.edgesuite.net/ondemand/Big%20Buck%20Bunny%20Adaptive.ism/Manifest" />
</p:Player>
</Grid>
</UserControl>
Build the application and watch the streaming movie. There is nothing more satisfying than getting something (anything) working!
The Silverlight HyperVideo Project has made two guest appearances on Silverlight TV.
In the first, I talk with John Papa about the project itself and how it has evolved.
Then, during Mix, Tim Heuer and I sat down with John to discuss What’s New In Silverlight 4, and I managed to sneak in a few comments about the HVP as well.
Silverlight TV has numerous great interviews, and is quickly becoming a valued asset throughout the Silverlight community.
Tens of thousands of people view each episode. Check it out here.
Then take a look at John Papa’s site as well.
Then come back here, because the last thing I want is for you to decide you like JP so much you stop visiting. Next thing you know, I’m sitting in the dark.
Two architectural demands for the Silverlight HVP, which are common to many larger applications, came together this week and crystallized into a design that looks to solve a couple other, unanticipated requirements. Specifically, we knew that (1) we wanted to have configuration files and that (2) we wanted each module to be created independently of all the other modules. After some discussion, thrashing, input from some great folks at CodeMash, and further review, the design that has emerged allows us to implement two other less thought-through requirements: (3) the ability to restore the state of the application to an earlier condition and (4) the ability to save the state of the application when it is shut down.